Skip to content

Const enums should be considered compile-time constants for computed property names #10770

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

TypeScript Version: 1.8.0

Code

const enum Color {
    Blue,
    Red = 1
}

interface IColors {
    // Error: A computed property name in an interface must be a compile-time constant
    [Color.Blue]: any;
    [Color.Red]: any;

    // No errors thrown
    [2]: any;
}

Expected behavior:
No red squigglies

Actual behavior:
Red squigglies, because a const enum's value isn't considered a compile-time constant (isn't it?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions