Skip to content
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

Ts infer optional params from effect handler #214

Conversation

bloadvenro
Copy link
Contributor

@bloadvenro bloadvenro commented Oct 6, 2019

The problem with current createEffect typescript typings is that FN extends () => infer Done condition satisfies zero-or-one-arity effect handlers. Handler like (x?: TYPE) => any will produce Effect<void,...>. New test suite with updated snapshots displays these errors.

You may see new typings proposal partially improving current situation. I added some comments to explain why it was difficult to deal with type any.

The last commit contains finally updated snapshots to demonstrate how proposed typings work.

@vercel
Copy link

vercel bot commented Oct 6, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://effector-git-fork-bloadvenro-ts-infer-optional-par-adab11.zerobias.now.sh

@zerobias
Copy link
Member

zerobias commented Oct 6, 2019

Wow, amazing! 😃 Big thanks!

@zerobias zerobias merged commit 880c2f3 into effector:master Oct 6, 2019
@bloadvenro bloadvenro deleted the ts-infer-optional-params-from-effect-handler branch Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants