Skip to content

Type inference in conditional types doesn't respect constraints #21937

@falsandtru

Description

@falsandtru

cc @ahejlsberg

TypeScript Version: master

Search Terms:

Code

type A<T extends string[]> = T extends Array<infer U> ? Record<U, {}> : never;

Expected behavior:

pass

Actual behavior:

$ node built/local/tsc.js --noEmit index.ts
index.ts(1,64): error TS2344: Type 'U' does not satisfy the constraint 'string'.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

Labels

Working as IntendedThe behavior described is the intended behavior; this is not a bug

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions