Skip to content

Indexer with type parameter #4896

Closed
Closed
@jbondc

Description

@jbondc
type MapThing<T> = {
    [x: string]: T; // Property 'length' of type 'number' is not assignable to string index type 'T'.
    length: number;
}
let a: MapThing<number>;
let b: MapThing<string>;

interface MapThingi<T> {
    [x: string]: T; // Property 'length' of type 'number' is not assignable to string index type 'T'.
    length: number;
}
let c: MapThingi<number>;
let d: MapThingi<string>;

A type parameter on an indexer is checked eagerly, should happen on instantiation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions