-
-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Labels
bugSomething isn't workingSomething isn't workingtypingsTypescript public type definitions issuesTypescript public type definitions issues
Milestone
Description
What is the current behavior:
The sample operator allows sampling from unknown to narrower types.
Steps to reproduce:
www.typescriptlang.org/play
import { createEvent, forward, sample } from 'effector'
const emitUnknown = createEvent<unknown>()
const receiveNumber = createEvent<number>()
sample({
// @ts-expect-error: unused directive ❌
source: emitUnknown,
target: receiveNumber,
})
forward({
// @ts-expect-error: type 'unknown' is not assignable to type 'number'. ✅
from: emitUnknown,
to: receiveNumber,
})What is the expected behavior:
The "sample" is expected to work identically to the "forward" in this case: throw compilation error "type 'unknown' is not assignable to type 'number'"
Versions:
Reproduces on effector@22.1.2 and typescript@4.5.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingtypingsTypescript public type definitions issuesTypescript public type definitions issues