Skip to content

Bad type inference between identical mapped types #18338

@gcnew

Description

@gcnew

TypeScript Version: nightly (2.5.0-dev.20170908)

Code

type IdMapped<T> = { [K in keyof T]: T[K] }

declare const f: <T>() => IdMapped<T>;
declare const g: <U>() => { [K in keyof U]: U[K] };

// Type 'IdMapped<{}>' is not assignable to type '{ [K in keyof T]: T[K]; }'
const h: typeof g = f;

Expected behavior:
Should compile without errors. T should be inferred as U.

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