Skip to content

Index signature for tagged string has wrong keyof resultΒ #45772

Closed
@ahejlsberg

Description

@ahejlsberg

πŸ•— Version & Regression Information

This is the behavior in every version I tried.

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgJlAvFAzsATgSwHYHMoBkUA3lAPpnACGuAXFAOSYIMC+A3AFCiRQBKEAMYBGJCSgBtANYQQ9eAF162AK4BbAEYR0UDt3DQBggExijAe3RwAPPAA0UVZu0A+Lvt4BpUchkhzAGb8QsLsUFAA9BGOEABu2gD8HtCepr6ygcEmYZHR8JxAA

πŸ’» Code

type Id = string & { __tag: 'id '};
type Rec1 = { [key: Id]: number };
type Rec2 = Record<Id, number>;

type K1 = keyof Rec1;  // never?
type K2 = keyof Rec2;  // Id

πŸ™ Actual behavior

K1 is never.

πŸ™‚ Expected behavior

K1 is Id.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions