-
Notifications
You must be signed in to change notification settings - Fork 429
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
fix: Mark prototype
property of constructors as readonly
#968
base: main
Are you sure you want to change the base?
Conversation
We think this is probably a bit too big of a change for its value, I agree that it better reflects reality (example below) but it's hard to gauge a potential breaks from something like this.
|
I'm not sure I understand the reasoning here, your example looks like it will benefit from
|
(But I guess some polyfill can legally assign things to |
Can we move this PR forward? |
We nowadays have better testing and hopefully the CI in microsoft/TypeScript side repo can catch potential breakage @orta was talking about on DefinitelyTyped. PR welcome (assuming one would also try the CI on TS repo too) |
Before doing this, you probably need to consider microsoft/TypeScript#58296 as it may become necessary to remove the |
Not sure what those some would be. Would that be because of compatibility issue with packages? |
No, it's because the PR would actually enforce that you can't assign an object with a readonly property to one that has the same property but mutable, and that relationship also applies to interfaces extending other interfaces. So, you can't inherit a mutable prototype and then mark it as readonly or vice versa. But, maybe it would work out to mark all prototypes as readonly, it just doesn't seem like that's the way things are going based on the discussions about the PR. |
This more closely matches runtime behaviour.
It also causes code that would try to re‑assign the
prototype
property of WebIDL constructors to have the error caught at compile time, rather than at run time.