Open ehaynes99 opened 6 months ago
When a function parameter is of type unknown, it is allowed for all type checks. All 3 of the latter checks here should fail:
unknown
import * as tsd from 'tsd' const example1 = (value: number) => String(value) tsd.expectType<(value: number) => string>(example1) // true positive tsd.expectType<(value: string) => string>(example1) // true negative tsd.expectType<(value: Date) => string>(example1) // true negative const example2 = (value: unknown) => String(value) tsd.expectType<(value: number) => string>(example2) // FALSE POSITIVE tsd.expectType<(value: string) => string>(example2) // FALSE POSITIVE tsd.expectType<(value: Date) => string>(example2) // FALSE POSITIVE
Playground
When a function parameter is of type
unknown
, it is allowed for all type checks. All 3 of the latter checks here should fail:Playground