Skip to content

Members of mapped types are not contextually typed #16209

Closed
@Igorbek

Description

@Igorbek

TypeScript Version: 2.3.2, 2.4.1

Update: verified in 2.4.1, still not working

Code

declare function f<T>(obj: { [K in keyof T]: (arg: number) => T[K]; }): T;
const r = f({ a: x => x, b: y => 10 });

Expected behavior:
Type of r is { a: number, b: number}
Type of both x and y is number

Actual behavior:
Type of r is { a: numberany, b: number}
Type of both x and y is numberany

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDuplicateAn existing issue was already created

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions