π Search Terms
implicit any contextual type
π Version & Regression Information
- This changed between versions 5.9.3 and 6.0 - rc
β― Playground Link
Playground Link
π» Code
declare let x: { function: string }
export type AssertableState<T> = {
[P in keyof T as P]: (value: T[P]) => void;
}
declare function assert_state<T extends object>(o: T, state: AssertableState<T>): void;
assert_state(x, {
function: v => { } // v is string
})
declare function assert_state_bad<T extends object>(o: T, state: Omit<AssertableState<T>, "">): void;
assert_state_bad(x, {
function: v => { } // error - v is implictly any
})
π Actual behavior
The call to assert_state_bad fails because v is implicitly typed as any
π Expected behavior
Either should pass as in 5.9.3
Additional information about the issue
- Works without the
Omit
- Works without the
as P in the mapped type. (original mapping was more complicated, but identity mapping seems to trigger it too)
π Search Terms
implicit any contextual type
π Version & Regression Information
β― Playground Link
Playground Link
π» Code
π Actual behavior
The call to
assert_state_badfails becausevis implicitly typed asanyπ Expected behavior
Either should pass as in 5.9.3
Additional information about the issue
Omitas Pin the mapped type. (original mapping was more complicated, but identity mapping seems to trigger it too)