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

Allow predicate refinements for split #215

Merged
merged 1 commit into from Oct 7, 2019

Conversation

abliarsar
Copy link
Contributor

@abliarsar abliarsar commented Oct 7, 2019

const source = createEvent<string | number | null | {}>()

const events = split(source, {
    numbers: (a): a is number => typeof a === 'number',
    strings: (a): a is string => typeof a === 'string',
    not_refined: (a) => !!a,
})

// Event<number>, no error
events.numbers.map(a => a.toFixed())

// Event<string>, no error
events.strings.map(a => a.charCodeAt(0))

// still fails, object is possibly null
events.not_refined.map(a => a.toString())

@vercel
Copy link

vercel bot commented Oct 7, 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-abliarsar-split-typings.zerobias.now.sh

@zerobias
Copy link
Member

zerobias commented Oct 7, 2019

Good improvement 👍 👍

@zerobias zerobias merged commit edba87c into effector:master Oct 7, 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