Closed
Description
TypeScript Version: 3.5.0-dev.20190420
Code
// type Weird = U
type Weird = any extends infer U ? U : never;
// Type 'null' is not assignable to type 'U'.
const a: Weird = null;
// Type 'U' is not assignable to type 'string'.
const b: string = a;
// type AlsoWeird = U
type AlsoWeird = unknown extends infer U ? U : never;
Expected behavior: Infer some type
Actual behavior: The extends clause leaks a temporary type U. Happens for any
and unknown
Playground Link: Playground