Skip to content

T[K] not assignable even when it's 'any' #23940

@ghost

Description

TypeScript Version: 2.9.0-dev.20180430

Code

interface I {
    x: any;
}
type Foo<T extends number> = T;
declare function f<K extends keyof I>(type: K): Foo<I[K]>;

Expected behavior:

No error.

Actual behavior:

src/a.ts:5:53 - error TS2344: Type 'I[K]' does not satisfy the constraint 'number'.

5 declare function f<K extends keyof I>(type: K): Foo<I[K]>;

This was broken by #23768 (fc2f16c): tested that it worked in the commit before it, 4e401ca .

Discovered in ember-data on DefinitelyTyped.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions