Skip to content

Incorrect index signature parameter type error #18759

Closed
@mbrodersen

Description

@mbrodersen

Version

$ ./node_modules/typescript/bin/tsc --version
Version 2.4.2

Code

type ClientId = number;

interface Clients {[key:ClientId]:any};

Expected behavior

No compiler errors.

Actual behavior

error TS1023: An index signature parameter type must be 'string' or 'number'.

Comment

ClientId is a number and Typescript is using structural typing - not nominative typing.

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