Skip to content

Improvements for compose #5

@reggi

Description

@reggi

Cool library! I've been hunting / trying to make a good compositional library with typescript support.

In my initial test here:

import { compose } from '@arrows/composition'
 
const addPrefixes = compose(
  (text: string) => `prefix1-${text}`,
  (text: string) => 3,
  (text: string) => `prefix2-${text}`,
)
 
addPrefixes('arrows') // -> "prefix1-prefix2-arrows"

Here are some thoughts on how to improve typing:

  1. The parameter type of addPrefixes should be string, because it's the parameter of the first function in compose.
  2. You can see above I have the 2nd function which returns 3 and the 4th which takes a string and that shouldn't be allowed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions