-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
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'.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this