Skip to content

Can't use alias of string as an index signature parameter type #7374

@mullens

Description

@mullens

The compiler requires an index signature parameter to be "string" or "number" specifically, and doesn't allow type aliases.

type CustomId = string;

interface Works {
    [customId: string]: string;
}
interface DoesNotWork {
    [customId: CustomId]: string;
}
// An index signature parameter type must be 'string' or 'number'.

Shouldn't CustomId be allowed there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions