Skip to content
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

Refactors to align ecmascript.mjs with spec text #1975

Merged
merged 1 commit into from Dec 13, 2021

Conversation

justingrant
Copy link
Collaborator

This PR is a few minor refactors for issues caught in temporal-polyfill. The common theme here is to better align polyfill code with current spec text.

  1. PrepareTemporalFields should throw (not return false) if its input is not an Object, which is what the spec says. Fixes Polyfill vs. spec mismatch in PrepareTemporalFields #1963.
  2. Refactor ToPartialRecord to better align wtih the spec text. Also removes parameter callerCast which isn't in the spec and isn't used elsewhere in the polyfill. (Thanks to TS for finding that!)
  3. Add assertion (like the spec has) in DisambiguatePossibleInstants to catch bad option values.

This PR is a few minor refactors for issues caught in temporal-polyfill.
The common theme here is to better align polyfill code wtih current
spec text.

1. PrepareTemporalFields should throw (not return false) if its input
   is not an Object, which is what the spec says. Fixes tc39#1963.
2. Refactor ToPartialRecord to better align wtih the spec text. Also
   removes parameter `callerCast` which isn't in the spec and isn't
   used elsewhere in the polyfill. (Thanks to TS for finding that!)
3. Add assertion to DisambiguatePossibleInstants for bad option value.
@justingrant justingrant added no-spec-text PR can be ignored by implementors non-prod-polyfill THIS POLYFILL IS NOT FOR PRODUCTION USE! labels Dec 13, 2021
@codecov
Copy link

codecov bot commented Dec 13, 2021

Codecov Report

Merging #1975 (47e1f6e) into main (4ef2748) will decrease coverage by 0.01%.
The diff coverage is 76.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1975      +/-   ##
==========================================
- Coverage   95.00%   94.98%   -0.02%     
==========================================
  Files          19       19              
  Lines       10941    10943       +2     
  Branches     1739     1739              
==========================================
  Hits        10394    10394              
- Misses        531      533       +2     
  Partials       16       16              
Flag Coverage Δ
test262 80.04% <54.54%> (+<0.01%) ⬆️
tests 89.82% <69.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 95.19% <76.92%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ef2748...47e1f6e. Read the comment docs.

@Ms2ger Ms2ger merged commit 93fe7b8 into tc39:main Dec 13, 2021
justingrant added a commit to justingrant/temporal-polyfill that referenced this pull request Dec 13, 2021
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.
justingrant added a commit to justingrant/temporal-polyfill that referenced this pull request Dec 13, 2021
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.
justingrant added a commit to justingrant/temporal-polyfill that referenced this pull request Dec 13, 2021
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.
justingrant added a commit to justingrant/temporal-polyfill that referenced this pull request Dec 15, 2021
justingrant added a commit to js-temporal/temporal-polyfill that referenced this pull request Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-spec-text PR can be ignored by implementors non-prod-polyfill THIS POLYFILL IS NOT FOR PRODUCTION USE!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Polyfill vs. spec mismatch in PrepareTemporalFields
2 participants