Skip to content

Allow defining static index signature #6480

Closed
@iby

Description

@iby
class Foo {
    [key: string]: any;
    static BAR:string = 'bar';
    static BAZ:string = 'baz';
}

console.log(Foo['BAR']);
console.log(Foo['B' + 'A' + 'Z']);
console.log(Foo['qux']);

I get the following errors with this:

tst.ts(8,13): error TS7017: Index signature of object type implicitly has an 'any' type.
tst.ts(9,13): error TS7017: Index signature of object type implicitly has an 'any' type.

I've read in the gitter archives that this should be working. Should it? How can I get a static property value using a dynamic key?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions