You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, index signature parameter type must be string or number.
Now that Typescript supports String literal types, it would be great if it could be used for index signature parameter type as well.
For example:
type MyString = "a" | "b" | "c";
var MyMap:{[id:MyString] : number} = {};
MyMap["a"] = 1; // valid
MyMap["asd"] = 2; //invalid
It would be also useful if it could also work with Enums. For example:
enum MyEnum {
a = <any>"a",
b = <any>"b",
c = <any>"c",
d = <any>"d",
}
var MyMap:{[id:MyEnum] : number} = {};
MyMap[MyEnum.a] = 1; // valid
MyMap["asd"] = 2; //invalid
var MyMap:{[id:MyEnum] : number} = {
[MyEnum.a]:1, // valid
"asdas":2, //invalid
}
The text was updated successfully, but these errors were encountered:
At the moment, index signature parameter type must be string or number.
Now that Typescript supports String literal types, it would be great if it could be used for index signature parameter type as well.
For example:
It would be also useful if it could also work with Enums. For example:
The text was updated successfully, but these errors were encountered: