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

lib.d.ts: add missing TypedArray-from-iterable signatures #58188

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Renegade334
Copy link
Contributor

Resolves #45198
Resolves #45199

There are stale PRs linked to these issues, but those involved wider remodelling of the array library. This should be simple enough to merge independently.

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Apr 14, 2024
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 14, 2024

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

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests comparing main and refs/pull/58188/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

@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
Angular - node (v18.15.0, x64)
Memory used 296,982k (± 0.01%) 297,039k (± 0.01%) +57k (+ 0.02%) 297,020k 297,066k p=0.005 n=6
Parse Time 2.70s (± 0.28%) 2.70s (± 0.43%) ~ 2.69s 2.72s p=0.734 n=6
Bind Time 0.82s (± 0.50%) 0.83s (± 0.66%) ~ 0.82s 0.83s p=0.282 n=6
Check Time 8.33s (± 0.42%) 8.35s (± 0.31%) ~ 8.32s 8.39s p=0.295 n=6
Emit Time 7.07s (± 0.46%) 7.06s (± 0.21%) ~ 7.04s 7.07s p=0.743 n=6
Total Time 18.91s (± 0.22%) 18.93s (± 0.18%) ~ 18.90s 18.98s p=0.466 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,395k (± 0.75%) 191,856k (± 0.07%) ~ 191,773k 192,110k p=1.000 n=6
Parse Time 1.35s (± 0.38%) 1.34s (± 0.62%) ~ 1.33s 1.35s p=0.070 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.59s (± 0.44%) 9.57s (± 0.32%) ~ 9.51s 9.60s p=0.293 n=6
Emit Time 2.63s (± 0.54%) 2.62s (± 0.78%) ~ 2.59s 2.65s p=0.289 n=6
Total Time 14.29s (± 0.27%) 14.25s (± 0.23%) ~ 14.19s 14.29s p=0.106 n=6
Monaco - node (v18.15.0, x64)
Memory used 348,853k (± 0.01%) 348,855k (± 0.01%) ~ 348,830k 348,895k p=0.810 n=6
Parse Time 2.55s (± 0.67%) 2.54s (± 0.32%) ~ 2.53s 2.55s p=0.402 n=6
Bind Time 0.89s (± 0.00%) 0.89s (± 0.00%) ~ 0.89s 0.89s p=1.000 n=6
Check Time 7.03s (± 0.27%) 7.05s (± 0.39%) ~ 7.02s 7.09s p=0.195 n=6
Emit Time 4.06s (± 0.39%) 4.05s (± 0.36%) ~ 4.03s 4.07s p=0.459 n=6
Total Time 14.54s (± 0.26%) 14.53s (± 0.22%) ~ 14.49s 14.57s p=1.000 n=6
TFS - node (v18.15.0, x64)
Memory used 302,957k (± 0.00%) 302,959k (± 0.01%) ~ 302,938k 302,983k p=0.872 n=6
Parse Time 2.98s (± 1.22%) 2.98s (± 0.99%) ~ 2.95s 3.02s p=0.809 n=6
Bind Time 1.44s (± 0.44%) 1.44s (± 0.36%) ~ 1.44s 1.45s p=0.386 n=6
Check Time 9.40s (± 0.44%) 9.38s (± 0.48%) ~ 9.33s 9.45s p=0.687 n=6
Emit Time 5.30s (± 0.48%) 5.31s (± 1.14%) ~ 5.24s 5.41s p=0.870 n=6
Total Time 19.11s (± 0.44%) 19.12s (± 0.42%) ~ 19.04s 19.26s p=0.872 n=6
material-ui - node (v18.15.0, x64)
Memory used 511,594k (± 0.01%) 511,622k (± 0.00%) ~ 511,592k 511,650k p=0.128 n=6
Parse Time 2.71s (± 0.68%) 2.70s (± 0.95%) ~ 2.68s 2.74s p=0.361 n=6
Bind Time 0.99s (± 1.04%) 0.99s (± 1.28%) ~ 0.97s 1.00s p=0.868 n=6
Check Time 17.25s (± 0.24%) 17.20s (± 0.19%) -0.05s (- 0.31%) 17.16s 17.23s p=0.041 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.96s (± 0.19%) 20.89s (± 0.13%) -0.07s (- 0.33%) 20.86s 20.93s p=0.015 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,748,702k (± 0.00%) 1,748,727k (± 0.00%) ~ 1,748,666k 1,748,761k p=0.574 n=6
Parse Time 9.95s (± 0.51%) 9.98s (± 0.73%) ~ 9.91s 10.10s p=0.374 n=6
Bind Time 3.32s (± 0.82%) 3.34s (± 0.65%) ~ 3.31s 3.37s p=0.418 n=6
Check Time 81.52s (± 0.31%) 81.80s (± 0.33%) ~ 81.37s 82.14s p=0.128 n=6
Emit Time 0.19s (± 2.67%) 0.19s (± 2.13%) ~ 0.19s 0.20s p=0.595 n=6
Total Time 94.99s (± 0.32%) 95.31s (± 0.33%) ~ 94.85s 95.76s p=0.230 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,306,325k (± 0.04%) 2,307,177k (± 0.04%) ~ 2,305,417k 2,308,171k p=0.298 n=6
Parse Time 7.34s (± 0.93%) 7.35s (± 1.22%) ~ 7.24s 7.46s p=0.810 n=6
Bind Time 2.76s (± 0.82%) 2.73s (± 0.38%) -0.03s (- 1.09%) 2.71s 2.74s p=0.045 n=6
Check Time 49.24s (± 0.97%) 49.43s (± 0.75%) ~ 49.04s 50.03s p=0.471 n=6
Emit Time 3.91s (± 2.89%) 3.87s (± 1.32%) ~ 3.81s 3.94s p=0.298 n=6
Total Time 63.27s (± 0.97%) 63.40s (± 0.66%) ~ 62.93s 64.06s p=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used 2,381,522k (± 0.04%) 2,381,650k (± 0.01%) ~ 2,381,077k 2,382,029k p=0.689 n=6
Parse Time 7.68s (± 1.11%) 7.65s (± 0.49%) ~ 7.60s 7.71s p=0.423 n=6
Bind Time 2.52s (± 1.35%) 2.53s (± 0.64%) ~ 2.51s 2.55s p=0.520 n=6
Check Time 49.70s (± 0.47%) 49.71s (± 0.59%) ~ 49.43s 50.17s p=1.000 n=6
Emit Time 4.01s (± 4.17%) 3.98s (± 1.78%) ~ 3.90s 4.08s p=0.936 n=6
Total Time 63.92s (± 0.46%) 63.88s (± 0.49%) ~ 63.50s 64.28s p=0.575 n=6
self-compiler - node (v18.15.0, x64)
Memory used 419,063k (± 0.00%) 419,150k (± 0.01%) +87k (+ 0.02%) 419,113k 419,184k p=0.005 n=6
Parse Time 3.40s (± 0.51%) 3.37s (± 2.10%) ~ 3.23s 3.43s p=0.512 n=6
Bind Time 1.31s (± 1.25%) 1.33s (± 2.73%) ~ 1.30s 1.40s p=0.241 n=6
Check Time 17.99s (± 0.38%) 18.07s (± 0.08%) ~ 18.05s 18.09s p=0.065 n=6
Emit Time 1.36s (± 2.05%) 1.40s (± 1.25%) +0.04s (+ 2.82%) 1.37s 1.42s p=0.035 n=6
Total Time 24.05s (± 0.32%) 24.17s (± 0.25%) +0.11s (+ 0.47%) 24.10s 24.24s p=0.025 n=6
vscode - node (v18.15.0, x64)
Memory used 2,913,518k (± 0.00%) 2,913,613k (± 0.00%) +96k (+ 0.00%) 2,913,556k 2,913,696k p=0.031 n=6
Parse Time 13.41s (± 0.25%) 13.40s (± 0.30%) ~ 13.34s 13.45s p=0.518 n=6
Bind Time 4.06s (± 0.30%) 4.10s (± 2.21%) ~ 4.03s 4.28s p=0.515 n=6
Check Time 72.65s (± 0.38%) 72.83s (± 0.34%) ~ 72.56s 73.18s p=0.298 n=6
Emit Time 19.46s (± 0.36%) 19.43s (± 0.35%) ~ 19.31s 19.49s p=0.469 n=6
Total Time 109.59s (± 0.28%) 109.75s (± 0.29%) ~ 109.45s 110.26s p=0.575 n=6
webpack - node (v18.15.0, x64)
Memory used 409,482k (± 0.02%) 409,529k (± 0.02%) ~ 409,416k 409,645k p=0.378 n=6
Parse Time 4.84s (± 0.73%) 4.84s (± 0.77%) ~ 4.80s 4.88s p=1.000 n=6
Bind Time 2.02s (± 1.07%) 2.02s (± 0.96%) ~ 1.99s 2.04s p=0.744 n=6
Check Time 21.01s (± 0.54%) 21.01s (± 0.35%) ~ 20.88s 21.08s p=1.000 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 27.87s (± 0.50%) 27.87s (± 0.23%) ~ 27.80s 27.97s p=0.575 n=6
xstate - node (v18.15.0, x64)
Memory used 672,017k (± 0.02%) 672,130k (± 0.02%) ~ 671,984k 672,326k p=0.173 n=6
Parse Time 4.11s (± 0.45%) 4.11s (± 0.36%) ~ 4.09s 4.13s p=0.627 n=6
Bind Time 1.88s (± 0.88%) 1.88s (± 1.21%) ~ 1.86s 1.91s p=0.933 n=6
Check Time 3.45s (± 0.71%) 3.44s (± 0.50%) ~ 3.42s 3.47s p=0.935 n=6
Emit Time 0.02s (±21.89%) 0.03s (±26.54%) ~ 0.02s 0.04s p=0.476 n=6
Total Time 9.47s (± 0.51%) 9.46s (± 0.28%) ~ 9.41s 9.48s p=0.748 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - 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)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos comparing main and refs/pull/58188/merge:

Everything looks good!

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except I have one question about addition of Iterable in es2020.bigint

* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
*/
from(arrayLike: ArrayLike<bigint> | Iterable<bigint>): BigInt64Array;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do these differ from the types in TypeArray.from? For that one, we just use Iterable.

Some guesses:

  • es2020.bigint can be used without including es2015.iterable (or whatever file makes Arrays Iterable)
  • Iterable is added here because it's in TypedArray.from, but ArrayLike stays for backward compatibility.

Copy link
Contributor Author

@Renegade334 Renegade334 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in those cases, the ArrayLike overloads had already been defined in es5 prior to the introduction of iterables, so the ArrayLike signature and the Iterable signature exist as two separate overloads (eg. here and here). Since the bigint typed arrays are defined in es2020 for the first time, both need to be added here.

ArrayLike objects don't have to be iterable, so the method definitions need to accept both:

BigInt64Array.from(
  // ArrayLike<number> but not iterable
  {
    0: 12345678,
    1: 98765432,
    length: 2,
  },
  (n: number): bigint => BigInt(n) ** 2n,
) // BigInt64Array [ 152415765279684n, 9754610558146624n ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that subject, though, the bigint TypedArray constructors in es2020.bigint don't look like they have a new (ArrayLike<bigint>) signature, which probably also needs addressing.

Comment on lines +30 to +31
bigIntArray = BigInt64Array.from({0: 1n, 1: 2n, 2: 3n, length: 3});
bigIntArray = BigInt64Array.from({0: 1n, 1: 2n, 2: 3n, length: 3}, n => n * 10n);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re. this conversation, this is the case that necessitates keeping ArrayLike alongside Iterable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Waiting on author
4 participants