Skip to content

Ts infer optional params from effect handler#214

Merged
zerobias merged 3 commits into
effector:masterfrom
bloadvenro:ts-infer-optional-params-from-effect-handler
Oct 6, 2019
Merged

Ts infer optional params from effect handler#214
zerobias merged 3 commits into
effector:masterfrom
bloadvenro:ts-infer-optional-params-from-effect-handler

Conversation

@bloadvenro

Copy link
Copy Markdown
Contributor

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

vercel Bot commented Oct 6, 2019

Copy link
Copy Markdown

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

zerobias commented Oct 6, 2019

Copy link
Copy Markdown
Member

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 October 11, 2019 17:58
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.

2 participants