8000 Should treat const and enum (at least const enum) value the same as literals for indexers. · Issue #3411 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Should treat const and enum (at least const enum) value the same as literals for indexers. #3411
@vilicvane

Description

@vilicvane
const DATA_END_INDEX = 2;

enum OptimizedDataIndex {
    start,
    data,
    end
}

interface OptimizedData {
    0: number;
    1: any[];
    2: number;
}

var data: OptimizedData;
var start = OptimizedData[OptimizedDataIndex.start];
var end = OptimizedData[DATA_END_INDEX];
// expecting no error. `start` and `end` should be numbers.

This should also apply to something like tuples directly written as [TypeA, TypeB, ...].

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".FixedA PR has been merged for this issueHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0