-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: TypeScript typings #157
base: master
Are you sure you want to change the base?
Conversation
packages/base/index.d.ts
Outdated
__tag: 'Just'; | ||
value: A; | ||
map<B>(f: (_: A) => B): Maybe<B>; | ||
apply<B>(this: Maybe<(_: A) => B>, f: Maybe<A>): Maybe<B>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this type incorrect i think. We use the Generic variable A
here for other Maybe, it cause typescript infer the this
context must be Maybe<(_: (_: A) => B) => B>
. To make it clear try: ma.map(tuple).apply(mb)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apply<B, C>(this: Maybe<(_: B) => C>, other: Maybe<B>): Maybe<C>
might do the trick, don't use the A
variable in Generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the A type variable should be local to that method.
Well, overloaded functions on arrays will have to be replaced by static arity functions. Too many silent type errors from TypeScript otherwise :/ |
|
This adds partial support for Core, Validation, Result, and Maybe
TypeScript can't distinguish between them correctly :(
5f59067
to
7191280
Compare
|
packages/base/index.d.ts
Outdated
toString(): string; | ||
equals(that: Maybe<A>): boolean; | ||
unsafeGet(): A; | ||
fold<B>(onJust: (_: A) => B, onNothing: () => B): B; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is inverted, onNothing
is first and onJust
in second
packages/base/index.d.ts
Outdated
toString(): string; | ||
equals(that: Maybe<A>): boolean; | ||
unsafeGet(): A; | ||
fold<B>(onJust: (_: A) => B, onNothing: () => B): B; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same case I've mentioned in the comment above
3.0.1-ts fixes .fold and .fromNullable in Maybe |
Semigroup types don't work with TS 2.8.1 |
This PR tracks the work on TypeScript typings (#65). These will work with Folktale 2.x. There's a separate branch to rewrite Folktale in TypeScript (#115). That'll be a breaking change (using ES6 modules), and thus a new major version. TypeScript in Folktale will likely be released early 2018.
Current status
v3.0.1-ts is available on the
tstypes
channel:npm install folktale@tstypes
[ ]
adt (note that adt fundamentally can't have useful types)[X]
concurrency[X]
conversions[/]
core (missingcurry
&partialize
)[ ]
fantasy-land[/]
maybe[/]
result[/]
validation[/]
indicates partial support,[X]
indicates full support.