Skip to content

extends clause leaks temporary type #31099

Closed
@SimonMeskens

Description

@SimonMeskens

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions