Closed
Description
Given:
interface Foo {
[key: string | number]: boolean;
}
I get
bleh.ts(2,4): error TS1023: An index signature parameter type must be 'string' or 'number'.
A workaround is:
interface Foo {
[key: number]: boolean;
[key: string]: boolean;
}
But, I need to match up the type of value, boolean
. Since it's a repetition, it could be useful to programmers to specify index signature parameter type as string
, number
, string | number
, or number | string
.