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 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())
@now

This comment has been minimized.

Copy link

now 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 added a commit that referenced this pull request Oct 7, 2019
@zerobias

This comment has been minimized.

Copy link
Owner

zerobias commented Oct 7, 2019

Good improvement 👍 👍

@zerobias zerobias merged commit edba87c into zerobias:master Oct 7, 2019
4 checks passed
4 checks passed
common-tests
Details
WIP Ready for review
Details
now Deployment has completed
Details
semaphoreci The build passed on Semaphore.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.