Skip to content

Mapped types with type parameter are not assignable to { [key: string]: any} #12900

@wonderful-panda

Description

@wonderful-panda

TypeScript Version: 2.1.4 and nightly(2.2.0-dev.20161213)

Code

interface Base {
   foo: { [key: string]: any };
   bar: any;
   baz: any;
}

interface E1<T> extends Base {
  foo: T;
}

interface Something { name: string, value: string };
interface E2 extends Base {
  foo: Partial<Something>;  // or other mapped type
}

interface E3<T> extends Base {
  foo: Partial<T>; // or other mapped type
}

Expected behavior:
Successfully compiled.

Actual behavior:
E1 and E2 are OK, but E3 causes compile error.

error TS2430: Interface 'E3<T>' incorrectly extends interface 'Base'.
Types of property 'foo' are incompatible.
Type 'Partial<T>' is not assignable to type '{ [key: string]: any; }'.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions