Skip to content

Mapped types over keyof T should be subtypes of types with string index signatures #14548

Description

@cwmacdon

TypeScript Version: 2.2.1

Code

// helpers to map types
type Dictionary = {
    [key: string]: string;
};

interface IBaseEntity {
    name: string;
    properties: Dictionary;
}
interface IEntity<t> extends IBaseEntity {
    properties: Record<t, string>;
}

Expected behaviour:
No Compile error.

Actual behaviour:
Compile error:

Interface 'IEntity<t>' incorrectly extends interface 'IBaseEntity'.
  Types of property 'properties' are incompatible.
    Type 'Record<t, string>' is not assignable to type 'Dictionary'.

Edit: Replace StrictDictionary with Record<t, string>. Show full compile error.

Metadata

Metadata

Assignees

Labels

CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for 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