Skip to content

Unexpected error when mixing index signature with generic mapped type #29246

@OliverJAsh

Description

@OliverJAsh

TypeScript Version: 3.2.2

Search Terms: mapped types index signature incompatible function

Code

declare const fn: <K extends string, V>(object: { [Key in K]: V }) => object;
declare const a: { [index: string]: number };
/*
Argument of type '{ [index: string]: number; }' is not assignable to parameter of type '{ [x: string]: never; }'.
  Index signatures are incompatible.
    Type 'number' is not assignable to type 'never'.
*/
fn(a);

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

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