Union index signature parameter type has unclear / incorrect error #33427
Labels
Bug
A bug in TypeScript
Domain: Error Messages
The issue relates to error messaging
Fixed
A PR has been merged for this issue
Good First Issue
Well scoped, documented and has the green light
Help Wanted
You can do this
Milestone
TypeScript Version: 3.7.0-dev.20190913
Search Terms:
Code
Expected behavior:
Either the following error message is displayed, or the error message makes it clear that only one of
string
xornumber
is permissible as an index signature parameter type.TypeScript/src/compiler/diagnosticMessages.json
Lines 962 to 965 in 038d951
Actual behavior:
To me, the expression
string | number
is equivalent to the phrase "'string' or 'number'", but the phrasing is not precise.Either the wrong error is being thrown, or this TS1023 should be clarified to say "...must be one of 'string' or 'number'." or "...must be either 'string' or 'number'."
TypeScript/src/compiler/diagnosticMessages.json
Lines 74 to 77 in 038d951
Playground Link:
(error not shown in Playground)
Related Issues:
#2611
#2049
#8711
#18759
I will fix this in a PR if you tell me whether TS1023 is the right error with a fixed message, or if TS1337 should be thrown instead of TS1023.
The text was updated successfully, but these errors were encountered: