-
-
Notifications
You must be signed in to change notification settings - Fork 260
Closed
Labels
typingsTypescript public type definitions issuesTypescript public type definitions issues
Description
Sample typings is incomplete for config case.
const source = createStore<string>('')
const event = createEvent<number>()
const target = createEvent<number>()
// Fine
const case1 = sample(source, event, (a, b) => 1)
const store = createStore<number>()
const event2 = createEvent<string>()
// Should be Event<number>, not Event<string>
const case1bug = sample(event2, store, (a,b) => 1)
// No errors, but case2 should be Event, not Unit
// It doesn't matter tho, because we can use methods of target
const case2 = sample({
source,
clock: event,
fn: (a, b) => 1,
target
})
// TS complains about arguments of fn
// TS7006: Parameter 'a' implicitly has an 'any' type.
// TS7006: Parameter 'b' implicitly has an 'any' type.
const case3 = sample({
source,
clock: event,
fn: (a, b) => 1
})
// And case3 is completely useless, because it has Unit type
// TS2339: Property 'filterMap' does not exist on type 'Unit<number>'.
case3.filterMap(a => a === 1 ? a : undefined)
// Can't cast it
// TS2740: Type 'Unit<number>' is missing the following properties from type 'Event<number>': watch, map, filter, filterMap, and 5 more.
const t: Event<number> = case3Metadata
Metadata
Assignees
Labels
typingsTypescript public type definitions issuesTypescript public type definitions issues