-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS 4.1+ Key remapping in mapped types allows bypassing statically known members check #43189
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
Seems like a feature to me 🤷 |
I'm confused what When hovering over When mapping it to another type and providing type arguments, e.g. |
My version uses |
Please don't take a production dependency on this; I have no idea what might be hiddenly broken when that type starts getting used. |
it would be great if this was an actual feature. "dynamically" adding typings would be great in some scenarios |
👍 ; thinking back now, I remember having some really cryptic bugs that were fixed when I stopped using this behavior |
Bug Report
🔎 Search Terms
key remapping static member, arbitrary interface keys, bypassing interface dynamic member check
🕗 Version & Regression Information
With the key remapping introduced in TS 4.1 for mapped types, the following error can be bypassed:
I was unable to test this on prior versions because key remapping didn't exist.
⏯ Playground Link
💻 Code
🙁 Actual behavior
TypeScript inconsistently prevents using interfaces with dynamic members.
🙂 Expected behavior
Either
RecordInterface
to have an error, or to be able to replaceRecord1
withRecord
without any error.CC: @tjjfvi, who discovered this, but hasn't submitted a bug.
There is a feature request (#41383) about changing the definition of
Pick
which includes a comment about this.The text was updated successfully, but these errors were encountered: