-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Static class properties not fitting into index signature types #42401
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
My workaround for this esoteric problem has been to create a static property const object with all properties I would have put into the static class.
becomes
|
There are places where we allow a string index signature to be inferred, and places we don't. The general principle is that declaration merging should not be able to induce an error due to index signature violation, and as you can see from where the errors occur, that's correctly happening. |
But, I think |
Declaration merging could allow non-prototype writes that would invalidate the signature |
Makes sense. Thanks for the explanation! |
Bug Report
🔎 Search Terms
static class index signature missing
🕗 Version & Regression Information
Tested on 3.9 and 4.2
Please keep and fill in the line that best applies:
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Each line here
errors
🙂 Expected behavior
No type errors. Or at least no errors for
{ ...D }
andObject.assign({}, D)
because those both result in{ a: 'a' }
, without the prototype or new().The text was updated successfully, but these errors were encountered: