-
-
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
Fix TypeScript type inference for functions passed to map #457
Conversation
This comment has been minimized.
This comment has been minimized.
I've pushed an additional set of test assertions to check that the requirements stipulated in #455 are met. As of yet, these assertions fail and I have been unable to find a type definition that causes the assertions to pass. |
Of course, if I replace the entire TS definition for export function map<RA, RB>(mapper: (value: RA) => RB):
<L>(source: FutureInstance<L, RA>) => FutureInstance<L, RB> The definition above is functionally equivalent to the definition that was used in Fluture v11. There is no support for the ConcurrentFuture type, and so while all the other assertions now pass, the ones for the ConcurrentFuture type fail (#401). |
The approach here was designed by @tjjfvi, who has been a tremendous help on the TypeScript Discord server. Thank you! Co-Authored-By: tjjfvi <[email protected]>
Switch to using a symbol instead of the 'input' property, to prevent this property, which is just used for passing around type information, from showing up in auto-completion as if it could be used at runtime.
Should I release this with a major version bump? I would prefer not to, but I find that when changing TS types, it usually probably breaks something for someone. |
We've kind of "narrowed" the type of |
This pull request tries to fix #455
I've started with a tsd setup to defend against regressions to before #401 and #403. Run
npm run test:types
to check that your typings have not introduced a regression.For context, here's the current TypeScript typings for
map
:Fluture/index.d.ts
Lines 137 to 143 in 2f12660
Also relevant, the type of
pipe
:Fluture/index.d.ts
Lines 36 to 37 in 2f12660