Skip to content

Enum error: Index signature parameter type must be string or number #3750

@vfonic

Description

@vfonic

Hi,

I have an object that has an Enum as key. The Enum values get eventualy compiled to number in JS.

I'd like to be able to specify this:
var mapping: { [mappingKey: MappingKey]: string; }
(MappingKey is Enum)

This doesn't work and throws compile errors.

Specifying mappingKey: number is not the correct behavior, as I would be able to do this in TS code then:
mapping[5] // this should throw compile error

This is a bit related to this issue:
#1415

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