Skip to content

Conversation

@abliarsar
Copy link
Contributor

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.

2 participants