Closed
Description
TypeScript Version: 2.4.2
Is there any reason for the following code failing to compile? As far as I'm aware, type aliases are resolved by TS quite early, so shouldn't the same be true in this case?
Code
type A = string;
type B = number;
type AIndexedNoAlias = {
[index: string]: any;
};
type AIndexedAlias = {
// An index signature parameter type must be 'string' or 'number'.
[index: A]: any;
};
type BIndexedNoAlias = {
[index: number]: any;
};
type BIndexedAlias = {
// An index signature parameter type must be 'string' or 'number'.
[index: B]: any;
};
Expected behavior:
The code above compiles
Actual behavior:
The code above fails to compile, with the following error: An index signature parameter type must be 'string' or 'number'.