-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Improve TypeScript type inference #374
Conversation
- Revert #230 and reintroduce the usage of the 'never' type - Relax the signature of chain and chainRej to allow TypeScript to derive types when merging a Future of a never with a Future of a real type. Closes #337 and closes #370. - Move generic types closer to where they are used in the function signature. Closes #372 and closes #373 through supersession. Co-authored-by: Edgar Rodriguez <edgarj.rodriguezg@gmail.com>
@davidchambers I asked you for a review because I know you've been working on typings for Sanctuary, and you would've likely encountered the same issues with |
This comment has been minimized.
This comment has been minimized.
Note that the changes I made to |
This comment has been minimized.
This comment has been minimized.
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.
Allowing TypeScript users to use untagged unions seems reasonable to me. I avoid them, but they are not inherently problematic in TypeScript.
Move generic types closer to where they are used in the function signature.
This is undoubtedly a good change.
Together with some regular TypeScript users I have tried to find a solution which does not compromise on the strictness of |
Breaking changes - #345 #383 The modular version of Fluture has been moved from `index.mjs` to 'index.js', and has been made compatible with Node 12. In Node 9, 10, and 11, the modular version must now be loaded with the help of the 'esm' loader. - #378 The 'fold' function has been renamed to 'coalesce'. - #377 The 'Future' constructor is no longer overloaded with a version that allows the computation to return 'void'. New features - #355 The npm package now ships with some of Fluture's testing internals. The API is experimental and subject to breaking changes. Improvements - #374 TypeScript types have been improved to get better inference.
After the discussions had in #337 and #370, I think our problems cannot be solved without compromising the strictness of the
chain
andchainRej
functions. This PR makes the following changes to get type inference to work well:derive types when merging a Future of a never with a Future of a
real type. Closes Stop using user-assignable type generics in the types of functions that don't do anything with them #337 and closes types of fold #370.
signature. Closes Move TypeScript generics as deeply into function signatures as possible #372 and closes Move the declaration of generics deeper into type signatures #373 through supersession.
/cc @edgarjrg, @tetsuo