-
-
Notifications
You must be signed in to change notification settings - Fork 264
Open
Labels
bugSomething isn't workingSomething isn't workingtypingsTypescript public type definitions issuesTypescript public type definitions issues
Description
What is the current behavior:
Currently typeguards in match field are not working in split
Following code
const $s = createStore<string | null>(null)
const valid = createEvent<string>()
const clk = createEvent()
split({
source: $s,
clock: clk,
match: {
valid: (str: string | null): str is string => Boolean(str),
},
cases: {
valid,
}
})gives type error like { error: "source type should extends cases"; sourceType: string | null; caseType: string; }
It can be workarounded by using other overload, where split actually creates events based on match typings
const $s = createStore<string | null>(null);
const valid = createEvent<string>();
const clk = createEvent();
const { validCase } = split(
sample({ source: $s, clock: clk }),
{
validCase: (str: string | null): str is string =>
Boolean(str),
}
);
sample({
clock: validCase,
target: valid,
});Please provide the steps to reproduce and if possible a minimal demo of the problem via https://share.effector.dev, https://codesandbox.io or similar
- https://tsplay.dev/wORPyW - broken example
- https://tsplay.dev/mLyleW - workaround
What is the expected behavior:
- Typeguards in
matchof config form ofsplitare working
Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
current latest release of effector@22
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtypingsTypescript public type definitions issuesTypescript public type definitions issues