-
Notifications
You must be signed in to change notification settings - Fork 153
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
Polyfill: Ensure that Temporal prototypes aren't writable #1974
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1974 +/- ##
==========================================
- Coverage 95.00% 94.96% -0.05%
==========================================
Files 19 19
Lines 10941 10953 +12
Branches 1739 1738 -1
==========================================
+ Hits 10394 10401 +7
- Misses 531 535 +4
- Partials 16 17 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
I can release the Babel fix later today if needed. |
This PR focuses on unblocking `strictNullChecks` and `strictPropertyInitialization` in ecmascript.ts and calendar.ts. It's intended as a complement to @jens-ox's work to remove `GetIntrinsic`. This PR: * Enables strictNullChecks: true and strictPropertyInitialization: true in tsconfig.json. * Improves calendar.ts TS types (this was most of the work in this PR) * Removes all unnecessary use of `any` throughout the polyfill * Updates types of ecmascript.ts and fixes a number of type bugs * Ports several proposal-temporal PRs: * tc39/proposal-temporal#1975 - Refactors to align ecmascript.mjs with spec text * tc39/proposal-temporal#1974 - Ensure that Temporal prototypes aren't writable * tc39/proposal-temporal#1976 - Throw RangeError if there's an invalid offset string in ZonedDateTime-representing property bags * Fixes a few index.d.ts types * Refactors a few types in intl.ts * A handful of trivial type changes in other files (ecmascript.ts and calendar-ts were 95%+ of the work). I'd like to split out the runtime behavior changes (mostly the ported PRs above) into a smaller PR which should make it easier to review changes that can actually break things at runtime. I also need to port tests over from tc39/proposal-temporal#1976. Once those are split out, this PR should be ready to review.
@nicolo-ribaudo - It's not urgent because I think we have a workaround, so the regular release schedule is fine for us. Thanks so much for jumping on this fix! |
This PR focuses on unblocking `strictNullChecks` and `strictPropertyInitialization` in ecmascript.ts and calendar.ts. It's intended as a complement to @jens-ox's work to remove `GetIntrinsic`. This PR: * Enables strictNullChecks: true and strictPropertyInitialization: true in tsconfig.json. * Improves calendar.ts TS types (this was most of the work in this PR) * Removes all unnecessary use of `any` throughout the polyfill * Updates types of ecmascript.ts and fixes a number of type bugs * Ports several proposal-temporal PRs: * tc39/proposal-temporal#1975 - Refactors to align ecmascript.mjs with spec text * tc39/proposal-temporal#1974 - Ensure that Temporal prototypes aren't writable * tc39/proposal-temporal#1976 - Throw RangeError if there's an invalid offset string in ZonedDateTime-representing property bags * Fixes a few index.d.ts types * Refactors a few types in intl.ts * A handful of trivial type changes in other files (ecmascript.ts and calendar-ts were 95%+ of the work). I'd like to split out the runtime behavior changes (mostly the ported PRs above) into a smaller PR which should make it easier to review changes that can actually break things at runtime. I also need to port tests over from tc39/proposal-temporal#1976. Once those are split out, this PR should be ready to review.
This PR focuses on unblocking `strictNullChecks` and `strictPropertyInitialization` in ecmascript.ts and calendar.ts. It's intended as a complement to @jens-ox's work to remove `GetIntrinsic`. This PR: * Enables strictNullChecks: true and strictPropertyInitialization: true in tsconfig.json. * Improves calendar.ts TS types (this was most of the work in this PR) * Removes all unnecessary use of `any` throughout the polyfill * Updates types of ecmascript.ts and fixes a number of type bugs * Ports several proposal-temporal PRs: * tc39/proposal-temporal#1975 - Refactors to align ecmascript.mjs with spec text * tc39/proposal-temporal#1974 - Ensure that Temporal prototypes aren't writable * tc39/proposal-temporal#1976 - Throw RangeError if there's an invalid offset string in ZonedDateTime-representing property bags * tc39/proposal-temporal#1977 - Refactor and fix non-ISO calendars in polyfill * Fixes a few index.d.ts types * Refactors a few types in intl.ts * A handful of trivial type changes in other files (ecmascript.ts and calendar-ts were 95%+ of the work). I'd like to split out the runtime behavior changes (mostly the ported PRs above) into a smaller PR which should make it easier to review changes that can actually break things at runtime. I also need to port tests over from tc39/proposal-temporal#1976. Once those are split out, this PR should be ready to review.
This PR fixes tc39#1965: 1. For Intl.DateTimeFormat, sets `writeable: false` on `prototype` because it's created using `function` (which has a writeable `prototype`, unlike `class` which is not writeable). 2. For Temporal classes, there's a Babel bug that causes prototypes to be writeable (babel/babel#2025) and this PR works around it.
b7bc297
to
5c1d078
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Fyi, we released the Babel fix yesterday. |
This PR fixes #1965:
writeable: false
onprototype
because it's created usingfunction
(which has a writeableprototype
, unlikeclass
which is not writeable).There are corresponding Test262 tests to check prototype writability here: tc39/test262#3344