Skip to content

Unable to use numeric enums as keys of a map #16842

Closed
@nevir

Description

@nevir

This appears to be a regression of #2491 (& #12425?)

TypeScript Version: 2.4.1

Code

Expected that this snippet does not produce errors, but it does:

enum Things { ONE, TWO }
// Error: Type 'Things' is not assignable to type 'string'. 
type ThingMap = {[TKey in Things]: boolean};

[Playground]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions