-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[Bug Report] Wrong keyof type with string index signature #39543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is by design
|
@IllusionMH Thanks for your quick reply. ❤️ What's the underlay reason of this "by design" ? 🤔 It looks odd and causes some strange type checking error in some third party packages |
I think it's because there's no difference between I guess it should be OK to use But I can be wrong here. |
Yeah a possible solution. I'll trying to submit a PR to that package. Thanks again~ 😄 |
TypeScript Version: 3.9.x
Search Terms: keyof, index signature
Code
Expected behavior:
KeyofTest1
should bestring
KeyofTest2
should benumber
Actual behavior:
KeyofTest1
isstring | number
(wrong)KeyofTest2
isnumber
(correct)Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=12&pc=1#code/JYOwLgpgTgZghgYwgAgCoQM5gIzIN4BQyxyA2gNYQCeAXMllKAOYC6dDzA3AQL4EFgqABxQBpagHsY6LLgC8ySlSlpMOfqEixEKGWABM+IiQrU6IAK4BbAEbQ29MIxBNufAcLGTpawwqUqevoEQA
Related Issues:
The text was updated successfully, but these errors were encountered: