Skip to content

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

Closed
René (Renegade334) wants to merge 12 commits into
microsoft:mainfrom
Renegade334:array-from-iterable
Closed

lib.d.ts: add missing TypedArray-from-iterable signatures#58188
René (Renegade334) wants to merge 12 commits into
microsoft:mainfrom
Renegade334:array-from-iterable

Conversation

@Renegade334

Copy link
Copy Markdown
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-botTypeScript Bot (typescript-bot) added the For Milestone Bug PRs that fix a bug with a specific milestone label Apr 14, 2024
@jakebailey

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 14, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used296,982k (± 0.01%)297,039k (± 0.01%)+57k (+ 0.02%)297,020k297,066kp=0.005 n=6
Parse Time2.70s (± 0.28%)2.70s (± 0.43%)~2.69s2.72sp=0.734 n=6
Bind Time0.82s (± 0.50%)0.83s (± 0.66%)~0.82s0.83sp=0.282 n=6
Check Time8.33s (± 0.42%)8.35s (± 0.31%)~8.32s8.39sp=0.295 n=6
Emit Time7.07s (± 0.46%)7.06s (± 0.21%)~7.04s7.07sp=0.743 n=6
Total Time18.91s (± 0.22%)18.93s (± 0.18%)~18.90s18.98sp=0.466 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used192,395k (± 0.75%)191,856k (± 0.07%)~191,773k192,110kp=1.000 n=6
Parse Time1.35s (± 0.38%)1.34s (± 0.62%)~1.33s1.35sp=0.070 n=6
Bind Time0.72s (± 0.00%)0.72s (± 0.00%)~0.72s0.72sp=1.000 n=6
Check Time9.59s (± 0.44%)9.57s (± 0.32%)~9.51s9.60sp=0.293 n=6
Emit Time2.63s (± 0.54%)2.62s (± 0.78%)~2.59s2.65sp=0.289 n=6
Total Time14.29s (± 0.27%)14.25s (± 0.23%)~14.19s14.29sp=0.106 n=6
Monaco - node (v18.15.0, x64)
Memory used348,853k (± 0.01%)348,855k (± 0.01%)~348,830k348,895kp=0.810 n=6
Parse Time2.55s (± 0.67%)2.54s (± 0.32%)~2.53s2.55sp=0.402 n=6
Bind Time0.89s (± 0.00%)0.89s (± 0.00%)~0.89s0.89sp=1.000 n=6
Check Time7.03s (± 0.27%)7.05s (± 0.39%)~7.02s7.09sp=0.195 n=6
Emit Time4.06s (± 0.39%)4.05s (± 0.36%)~4.03s4.07sp=0.459 n=6
Total Time14.54s (± 0.26%)14.53s (± 0.22%)~14.49s14.57sp=1.000 n=6
TFS - node (v18.15.0, x64)
Memory used302,957k (± 0.00%)302,959k (± 0.01%)~302,938k302,983kp=0.872 n=6
Parse Time2.98s (± 1.22%)2.98s (± 0.99%)~2.95s3.02sp=0.809 n=6
Bind Time1.44s (± 0.44%)1.44s (± 0.36%)~1.44s1.45sp=0.386 n=6
Check Time9.40s (± 0.44%)9.38s (± 0.48%)~9.33s9.45sp=0.687 n=6
Emit Time5.30s (± 0.48%)5.31s (± 1.14%)~5.24s5.41sp=0.870 n=6
Total Time19.11s (± 0.44%)19.12s (± 0.42%)~19.04s19.26sp=0.872 n=6
material-ui - node (v18.15.0, x64)
Memory used511,594k (± 0.01%)511,622k (± 0.00%)~511,592k511,650kp=0.128 n=6
Parse Time2.71s (± 0.68%)2.70s (± 0.95%)~2.68s2.74sp=0.361 n=6
Bind Time0.99s (± 1.04%)0.99s (± 1.28%)~0.97s1.00sp=0.868 n=6
Check Time17.25s (± 0.24%)17.20s (± 0.19%)-0.05s (- 0.31%)17.16s17.23sp=0.041 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.96s (± 0.19%)20.89s (± 0.13%)-0.07s (- 0.33%)20.86s20.93sp=0.015 n=6
mui-docs - node (v18.15.0, x64)
Memory used1,748,702k (± 0.00%)1,748,727k (± 0.00%)~1,748,666k1,748,761kp=0.574 n=6
Parse Time9.95s (± 0.51%)9.98s (± 0.73%)~9.91s10.10sp=0.374 n=6
Bind Time3.32s (± 0.82%)3.34s (± 0.65%)~3.31s3.37sp=0.418 n=6
Check Time81.52s (± 0.31%)81.80s (± 0.33%)~81.37s82.14sp=0.128 n=6
Emit Time0.19s (± 2.67%)0.19s (± 2.13%)~0.19s0.20sp=0.595 n=6
Total Time94.99s (± 0.32%)95.31s (± 0.33%)~94.85s95.76sp=0.230 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,306,325k (± 0.04%)2,307,177k (± 0.04%)~2,305,417k2,308,171kp=0.298 n=6
Parse Time7.34s (± 0.93%)7.35s (± 1.22%)~7.24s7.46sp=0.810 n=6
Bind Time2.76s (± 0.82%)2.73s (± 0.38%)-0.03s (- 1.09%)2.71s2.74sp=0.045 n=6
Check Time49.24s (± 0.97%)49.43s (± 0.75%)~49.04s50.03sp=0.471 n=6
Emit Time3.91s (± 2.89%)3.87s (± 1.32%)~3.81s3.94sp=0.298 n=6
Total Time63.27s (± 0.97%)63.40s (± 0.66%)~62.93s64.06sp=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used2,381,522k (± 0.04%)2,381,650k (± 0.01%)~2,381,077k2,382,029kp=0.689 n=6
Parse Time7.68s (± 1.11%)7.65s (± 0.49%)~7.60s7.71sp=0.423 n=6
Bind Time2.52s (± 1.35%)2.53s (± 0.64%)~2.51s2.55sp=0.520 n=6
Check Time49.70s (± 0.47%)49.71s (± 0.59%)~49.43s50.17sp=1.000 n=6
Emit Time4.01s (± 4.17%)3.98s (± 1.78%)~3.90s4.08sp=0.936 n=6
Total Time63.92s (± 0.46%)63.88s (± 0.49%)~63.50s64.28sp=0.575 n=6
self-compiler - node (v18.15.0, x64)
Memory used419,063k (± 0.00%)419,150k (± 0.01%)+87k (+ 0.02%)419,113k419,184kp=0.005 n=6
Parse Time3.40s (± 0.51%)3.37s (± 2.10%)~3.23s3.43sp=0.512 n=6
Bind Time1.31s (± 1.25%)1.33s (± 2.73%)~1.30s1.40sp=0.241 n=6
Check Time17.99s (± 0.38%)18.07s (± 0.08%)~18.05s18.09sp=0.065 n=6
Emit Time1.36s (± 2.05%)1.40s (± 1.25%)+0.04s (+ 2.82%)1.37s1.42sp=0.035 n=6
Total Time24.05s (± 0.32%)24.17s (± 0.25%)+0.11s (+ 0.47%)24.10s24.24sp=0.025 n=6
vscode - node (v18.15.0, x64)
Memory used2,913,518k (± 0.00%)2,913,613k (± 0.00%)+96k (+ 0.00%)2,913,556k2,913,696kp=0.031 n=6
Parse Time13.41s (± 0.25%)13.40s (± 0.30%)~13.34s13.45sp=0.518 n=6
Bind Time4.06s (± 0.30%)4.10s (± 2.21%)~4.03s4.28sp=0.515 n=6
Check Time72.65s (± 0.38%)72.83s (± 0.34%)~72.56s73.18sp=0.298 n=6
Emit Time19.46s (± 0.36%)19.43s (± 0.35%)~19.31s19.49sp=0.469 n=6
Total Time109.59s (± 0.28%)109.75s (± 0.29%)~109.45s110.26sp=0.575 n=6
webpack - node (v18.15.0, x64)
Memory used409,482k (± 0.02%)409,529k (± 0.02%)~409,416k409,645kp=0.378 n=6
Parse Time4.84s (± 0.73%)4.84s (± 0.77%)~4.80s4.88sp=1.000 n=6
Bind Time2.02s (± 1.07%)2.02s (± 0.96%)~1.99s2.04sp=0.744 n=6
Check Time21.01s (± 0.54%)21.01s (± 0.35%)~20.88s21.08sp=1.000 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time27.87s (± 0.50%)27.87s (± 0.23%)~27.80s27.97sp=0.575 n=6
xstate - node (v18.15.0, x64)
Memory used672,017k (± 0.02%)672,130k (± 0.02%)~671,984k672,326kp=0.173 n=6
Parse Time4.11s (± 0.45%)4.11s (± 0.36%)~4.09s4.13sp=0.627 n=6
Bind Time1.88s (± 0.88%)1.88s (± 1.21%)~1.86s1.91sp=0.933 n=6
Check Time3.45s (± 0.71%)3.44s (± 0.50%)~3.42s3.47sp=0.935 n=6
Emit Time0.02s (±21.89%)0.03s (±26.54%)~0.02s0.04sp=0.476 n=6
Total Time9.47s (± 0.51%)9.46s (± 0.28%)~9.41s9.48sp=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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Everything looks good!

Copy link
Copy Markdown
Member

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

Comment threadsrc/lib/es2020.bigint.d.ts Outdated
* 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
Copy Markdown
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.

@Renegade334René (Renegade334)Jun 14, 2024

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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 freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Milestone BugPRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypedArray constructors: missing from mapping iterable Big(Int|Uint)64ArrayConstructor: missing from Iterable

4 participants

@Renegade334@jakebailey@typescript-bot@sandersn