Add lib.esnext.temporal
Closes #60164.
No custom calendar support, as per the latest spec changes.
There are lots of places in the spec where property bags have "at least one of" constraints (eg. either month or monthCode is mandatory for a DateLikeObject), which can't really be straightforwardly expressed. Otherwise, appears to be playing well.
Temporal shipped in Firefox 139, and is staging in Chromium (shipping in 144).
We usually don't create tests for lib.d.ts like was done here; they're pretty annoying because they are typically very sensitive to tweaks, new lib.d.ts, etc. I think I missed this in the previous PR from you I merged, though.
Probably we should just delete them?
@typescript-bot test it
Starting jobs; this comment will be updated as builds start and complete.
| Command | Status | Results |
|---|---|---|
test top400 |
✅ Started | ✅ Results |
user test this |
✅ Started | ✅ Results |
run dt |
✅ Started | ✅ Results |
perf test this faster |
✅ Started | 👀 Results |
Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62628/merge:
There were infrastructure failures potentially unrelated to your change:
- 1 instance of "Git clone failed"
Otherwise...
Everything looks good!
Probably we should just delete them?
Dealer's choice. I needed them for testing anyway, but if they're of no value within the library then they can just go.
@jakebailey The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Errors | 34 | 34 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 62,370 | 62,370 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 50,386 | 50,386 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 195,219k (± 0.91%) | 194,013k (± 0.93%) | ~ | 192,756k | 196,339k | p=0.230 n=6 |
| Parse Time | 1.31s (± 0.42%) | 1.30s (± 0.31%) | ~ | 1.30s | 1.31s | p=0.282 n=6 |
| Bind Time | 0.72s (± 0.57%) | 0.72s (± 0.57%) | ~ | 0.72s | 0.73s | p=1.000 n=6 |
| Check Time | 9.76s (± 0.23%) | 9.74s (± 0.28%) | ~ | 9.70s | 9.78s | p=0.465 n=6 |
| Emit Time | 2.74s (± 0.85%) | 2.74s (± 0.64%) | ~ | 2.72s | 2.77s | p=0.622 n=6 |
| Total Time | 14.52s (± 0.18%) | 14.52s (± 0.18%) | ~ | 14.48s | 14.55s | p=0.872 n=6 |
| angular-1 - node (v18.15.0, x64) | ||||||
| Errors | 2 | 2 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 955,117 | 955,752 | +635 (+ 0.07%) | ~ | ~ | p=0.001 n=6 |
| Types | 415,619 | 415,621 | +2 (+ 0.00%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 1,254,564k (± 0.00%) | 1,255,717k (± 0.00%) | +1,153k (+ 0.09%) | 1,255,689k | 1,255,748k | p=0.005 n=6 |
| Parse Time | 6.49s (± 0.18%) | 6.52s (± 0.69%) | ~ | 6.48s | 6.59s | p=0.622 n=6 |
| Bind Time | 1.88s | 1.90s (± 0.27%) | +0.02s (+ 0.89%) | 1.89s | 1.90s | p=0.002 n=6 |
| Check Time | 32.17s (± 0.26%) | 32.16s (± 0.27%) | ~ | 32.01s | 32.25s | p=0.936 n=6 |
| Emit Time | 14.86s (± 0.35%) | 14.87s (± 0.56%) | ~ | 14.73s | 14.96s | p=0.687 n=6 |
| Total Time | 55.39s (± 0.09%) | 55.44s (± 0.27%) | ~ | 55.23s | 55.67s | p=0.423 n=6 |
| mui-docs - node (v18.15.0, x64) | ||||||
| Errors | 1 | 1 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 552,252 | 552,252 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 89 | 89 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 826,973k (± 0.00%) | 826,987k (± 0.00%) | ~ | 826,975k | 826,994k | p=0.065 n=6 |
| Parse Time | 8.59s (± 0.39%) | 8.59s (± 0.63%) | ~ | 8.54s | 8.69s | p=0.686 n=6 |
| Bind Time | 2.19s (± 0.47%) | 2.20s (± 0.47%) | ~ | 2.18s | 2.21s | p=0.560 n=6 |
| Check Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Emit Time | 0.27s (± 3.66%) | 0.26s (± 3.10%) | ~ | 0.26s | 0.28s | p=0.336 n=6 |
| Total Time | 11.05s (± 0.32%) | 11.05s (± 0.55%) | ~ | 11.00s | 11.16s | p=0.747 n=6 |
| self-build-src - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,237,232 | 1,237,239 | +7 (+ 0.00%) | ~ | ~ | p=0.001 n=6 |
| Types | 259,856 | 259,870 | +14 (+ 0.01%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 2,486,212k (±11.93%) | 2,607,270k (±14.39%) | ~ | 2,364,517k | 3,092,349k | p=0.378 n=6 |
| Parse Time | 5.19s (± 2.10%) | 5.18s (± 1.84%) | ~ | 5.09s | 5.33s | p=1.000 n=6 |
| Bind Time | 1.76s (± 1.33%) | 1.77s (± 1.04%) | ~ | 1.75s | 1.79s | p=0.803 n=6 |
| Check Time | 35.17s (± 0.57%) | 35.26s (± 0.26%) | ~ | 35.14s | 35.39s | p=0.173 n=6 |
| Emit Time | 3.00s (± 1.81%) | 3.00s (± 1.04%) | ~ | 2.97s | 3.04s | p=0.810 n=6 |
| Total Time | 45.13s (± 0.62%) | 45.22s (± 0.34%) | ~ | 44.98s | 45.39s | p=0.173 n=6 |
| self-build-src-public-api - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,237,232 | 1,237,239 | +7 (+ 0.00%) | ~ | ~ | p=0.001 n=6 |
| Types | 259,856 | 259,870 | +14 (+ 0.01%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 3,158,673k (± 0.04%) | 3,158,859k (± 0.02%) | ~ | 3,157,774k | 3,159,423k | p=0.936 n=6 |
| Parse Time | 6.87s (± 0.83%) | 6.88s (± 0.42%) | ~ | 6.83s | 6.91s | p=1.000 n=6 |
| Bind Time | 2.15s (± 1.75%) | 2.16s (± 1.16%) | ~ | 2.14s | 2.21s | p=0.335 n=6 |
| Check Time | 42.63s (± 0.39%) | 42.60s (± 0.34%) | ~ | 42.47s | 42.83s | p=0.575 n=6 |
| Emit Time | 3.51s (± 2.65%) | 3.52s (± 1.41%) | ~ | 3.42s | 3.55s | p=0.688 n=6 |
| Total Time | 55.15s (± 0.36%) | 55.18s (± 0.21%) | ~ | 55.03s | 55.39s | p=0.810 n=6 |
| self-compiler - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 262,534 | 262,541 | +7 (+ 0.00%) | ~ | ~ | p=0.001 n=6 |
| Types | 104,035 | 104,049 | +14 (+ 0.01%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 440,683k (± 0.01%) | 440,661k (± 0.01%) | ~ | 440,634k | 440,700k | p=0.173 n=6 |
| Parse Time | 3.51s (± 1.07%) | 3.52s (± 1.10%) | ~ | 3.46s | 3.56s | p=0.935 n=6 |
| Bind Time | 1.32s (± 1.07%) | 1.32s (± 0.74%) | ~ | 1.31s | 1.33s | p=0.869 n=6 |
| Check Time | 19.04s (± 0.32%) | 19.01s (± 0.27%) | ~ | 18.94s | 19.07s | p=0.470 n=6 |
| Emit Time | 1.53s (± 1.42%) | 1.52s (± 0.80%) | ~ | 1.51s | 1.54s | p=0.867 n=6 |
| Total Time | 25.39s (± 0.27%) | 25.37s (± 0.25%) | ~ | 25.30s | 25.45s | p=0.469 n=6 |
| ts-pre-modules - node (v18.15.0, x64) | ||||||
| Errors | 72 | 72 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 225,367 | 226,002 | +635 (+ 0.28%) | ~ | ~ | p=0.001 n=6 |
| Types | 94,290 | 94,290 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 370,202k (± 0.05%) | 371,083k (± 0.09%) | +882k (+ 0.24%) | 370,821k | 371,762k | p=0.005 n=6 |
| Parse Time | 2.83s (± 1.78%) | 2.86s (± 0.72%) | ~ | 2.83s | 2.89s | p=0.413 n=6 |
| Bind Time | 1.60s (± 1.02%) | 1.58s (± 0.65%) | ~ | 1.57s | 1.60s | p=0.157 n=6 |
| Check Time | 16.41s (± 0.39%) | 16.45s (± 0.54%) | ~ | 16.34s | 16.58s | p=0.520 n=6 |
| Emit Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Total Time | 20.84s (± 0.35%) | 20.89s (± 0.43%) | ~ | 20.77s | 21.00s | p=0.375 n=6 |
| vscode - node (v18.15.0, x64) | ||||||
| Errors | 5 | 5 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 3,948,486 | 3,948,486 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 1,239,521 | 1,239,521 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 3,741,034k (± 0.01%) | 3,741,057k (± 0.01%) | ~ | 3,740,702k | 3,741,213k | p=1.000 n=6 |
| Parse Time | 15.24s (± 0.65%) | 15.29s (± 0.52%) | ~ | 15.19s | 15.38s | p=0.336 n=6 |
| Bind Time | 4.97s (± 0.67%) | 5.31s (±15.07%) | ~ | 4.94s | 6.94s | p=0.376 n=6 |
| Check Time | 103.62s (± 4.59%) | 102.96s (± 3.47%) | ~ | 97.72s | 107.23s | p=0.689 n=6 |
| Emit Time | 37.03s (±15.24%) | 36.83s (± 7.55%) | ~ | 31.15s | 38.15s | p=0.689 n=6 |
| Total Time | 160.86s (± 2.48%) | 160.38s (± 1.86%) | ~ | 157.62s | 165.42s | p=0.936 n=6 |
| webpack - node (v18.15.0, x64) | ||||||
| Errors | 40 | 40 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 372,686 | 372,686 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 163,203 | 163,203 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 529,022k (± 0.02%) | 529,067k (± 0.02%) | ~ | 528,910k | 529,168k | p=0.471 n=6 |
| Parse Time | 4.50s (± 1.21%) | 4.51s (± 0.54%) | ~ | 4.48s | 4.55s | p=0.686 n=6 |
| Bind Time | 1.92s (± 1.12%) | 1.95s (± 0.68%) | ~ | 1.94s | 1.97s | p=0.056 n=6 |
| Check Time | 22.12s (± 0.22%) | 22.11s (± 0.61%) | ~ | 21.90s | 22.23s | p=0.470 n=6 |
| Emit Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Total Time | 28.55s (± 0.28%) | 28.57s (± 0.42%) | ~ | 28.37s | 28.68s | p=0.470 n=6 |
| xstate-main - node (v18.15.0, x64) | ||||||
| Errors | 30 | 30 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 676,516 | 677,157 | +641 (+ 0.09%) | ~ | ~ | p=0.001 n=6 |
| Types | 203,680 | 203,682 | +2 (+ 0.00%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 578,415k (± 0.03%) | 579,239k (± 0.02%) | +824k (+ 0.14%) | 579,025k | 579,349k | p=0.005 n=6 |
| Parse Time | 4.20s (± 1.22%) | 4.17s (± 0.60%) | ~ | 4.14s | 4.21s | p=0.292 n=6 |
| Bind Time | 1.34s (± 1.22%) | 1.36s (± 0.60%) | +0.02s (+ 1.36%) | 1.35s | 1.37s | p=0.039 n=6 |
| Check Time | 20.51s (± 2.02%) | 20.54s (± 1.81%) | ~ | 20.26s | 21.03s | p=0.688 n=6 |
| Emit Time | 0.00s | 0.00s (±154.76%) | ~ | 0.00s | 0.01s | p=0.174 n=6 |
| Total Time | 26.05s (± 1.63%) | 26.07s (± 1.41%) | ~ | 25.77s | 26.56s | p=1.000 n=6 |
- node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- angular-1 - node (v18.15.0, x64)
- mui-docs - node (v18.15.0, x64)
- self-build-src - node (v18.15.0, x64)
- self-build-src-public-api - node (v18.15.0, x64)
- self-compiler - node (v18.15.0, x64)
- ts-pre-modules - node (v18.15.0, x64)
- vscode - node (v18.15.0, x64)
- webpack - node (v18.15.0, x64)
- xstate-main - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
There are lot of places in the spec where property bags have "at least one of" constraints (eg. either
monthormonthCodeis mandatory for a DateLikeObject), which can't really be expressed.
Well...
type DateLikeObjectBase = {
year?: number | undefined;
era?: string | undefined;
eraYear?: number | undefined;
month?: number | undefined;
monthCode?: string | undefined;
day: number;
calendar?: string | undefined;
}
type DateLikeObject = DateLikeObjectBase & ({ month: number } | { monthCode: string });
Possibly it's not worth the additional complexity, though.
@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62628/merge:
Everything looks good!
I know there are existing polyfills for Temporal out there in TS; are these types compatible / based off of those? Or fresh?
The definitions are de novo, so no licensing issues.
As for compatibility:
temporal-polyfilldeclares a global Temporal namespace with divergent patterns (types instead of interfaces for dictionary definitions, ES6 classes instead of prototype/constructor interfaces, etc.) so will almost certainly never work with any lib.d.ts declaration in the same project.@js-temporal/polyfilldoesn't have interassignability with these definitions as things stand, not least due to some lib.d.ts patterns that aren't used there (| undefinedwith ExOPT, etc) – could run some proper tests if interoperability is a potential objective.