GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add __spreadArrays helper by rbuckton · Pull Request #31166 · microsoft/TypeScript

Conversation

@rbuckton

@rbuckton Ron Buckton (rbuckton) commented Apr 29, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds a __spreadArrays helper for a more accurate spread behavior when not using --downlevelIteration.

Fixes #8856

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rbuckton

Ron Buckton (rbuckton) commented Apr 29, 2019

Copy link
Copy Markdown
Contributor Author

TypeScript Bot (@typescript-bot) perf test

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 29, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at 528601f. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sheetalkamat
Sheetal Nandi (sheetalkamat) reviewed Apr 29, 2019
View reviewed changes
Comment thread src/compiler/factory.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 29, 2019

Copy link
Copy Markdown
Contributor

Ron Buckton (@rbuckton)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..31166

Metric master 31166 Delta Best Worst
Angular - node (v12.1.0, x64)
Memory used 313,388k (± 0.02%) 313,430k (± 0.02%) +42k (+ 0.01%) 313,303k 313,531k
Parse Time 1.38s (± 0.68%) 1.42s (± 0.94%) +0.04s (+ 2.83%) 1.40s 1.45s
Bind Time 0.73s (± 0.65%) 0.74s (± 1.13%) +0.00s (+ 0.27%) 0.72s 0.75s
Check Time 3.96s (± 0.59%) 3.98s (± 0.40%) +0.02s (+ 0.40%) 3.94s 4.00s
Emit Time 5.14s (± 0.82%) 5.14s (± 0.51%) +0.00s (+ 0.06%) 5.08s 5.19s
Total Time 11.21s (± 0.54%) 11.27s (± 0.40%) +0.06s (+ 0.51%) 11.15s 11.34s
Monaco - node (v12.1.0, x64)
Memory used 341,959k (± 0.02%) 342,000k (± 0.02%) +41k (+ 0.01%) 341,868k 342,106k
Parse Time 1.17s (± 0.66%) 1.19s (± 0.52%) +0.02s (+ 1.71%) 1.18s 1.20s
Bind Time 0.67s (± 0.97%) 0.67s (± 1.41%) +0.01s (+ 0.90%) 0.66s 0.70s
Check Time 4.06s (± 0.51%) 4.04s (± 0.43%) -0.02s (- 0.42%) 4.00s 4.09s
Emit Time 2.77s (± 0.59%) 2.76s (± 0.58%) -0.00s (- 0.14%) 2.74s 2.80s
Total Time 8.66s (± 0.30%) 8.67s (± 0.32%) +0.01s (+ 0.12%) 8.62s 8.74s
TFS - node (v12.1.0, x64)
Memory used 298,947k (± 0.01%) 298,897k (± 0.03%) -51k (- 0.02%) 298,743k 299,064k
Parse Time 0.92s (± 0.74%) 0.92s (± 0.96%) +0.01s (+ 0.87%) 0.90s 0.95s
Bind Time 0.62s (± 0.93%) 0.62s (± 0.60%) -0.00s (- 0.81%) 0.61s 0.62s
Check Time 3.62s (± 0.41%) 3.64s (± 0.55%) +0.02s (+ 0.58%) 3.58s 3.67s
Emit Time 2.86s (± 0.85%) 2.85s (± 0.86%) -0.00s (- 0.14%) 2.78s 2.91s
Total Time 8.01s (± 0.41%) 8.03s (± 0.43%) +0.02s (+ 0.27%) 7.94s 8.10s
Angular - node (v8.9.0, x64)
Memory used 330,848k (± 0.02%) 330,894k (± 0.02%) +46k (+ 0.01%) 330,786k 331,042k
Parse Time 1.78s (± 0.47%) 1.79s (± 0.27%) +0.02s (+ 1.01%) 1.78s 1.80s
Bind Time 0.79s (± 0.98%) 0.80s (± 0.86%) +0.01s (+ 0.63%) 0.78s 0.81s
Check Time 4.66s (± 1.58%) 4.62s (± 1.42%) -0.04s (- 0.90%) 4.48s 4.75s
Emit Time 5.88s (± 2.75%) 5.88s (± 2.64%) +0.00s (+ 0.03%) 5.60s 6.18s
Total Time 13.11s (± 0.98%) 13.09s (± 0.98%) -0.02s (- 0.16%) 12.85s 13.33s
Monaco - node (v8.9.0, x64)
Memory used 358,630k (± 0.02%) 358,689k (± 0.02%) +59k (+ 0.02%) 358,503k 358,904k
Parse Time 1.43s (± 0.34%) 1.45s (± 0.54%) +0.01s (+ 1.05%) 1.42s 1.46s
Bind Time 0.92s (± 0.67%) 0.90s (± 1.40%) -0.03s (- 2.82%) 0.87s 0.91s
Check Time 4.73s (± 0.45%) 4.86s (± 1.76%) +0.13s (+ 2.72%) 4.73s 5.04s
Emit Time 3.40s (± 0.54%) 3.15s (± 6.58%) -0.25s (- 7.38%) 2.80s 3.40s
Total Time 10.49s (± 0.32%) 10.36s (± 1.36%) -0.13s (- 1.23%) 10.10s 10.56s
TFS - node (v8.9.0, x64)
Memory used 314,046k (± 0.01%) 314,055k (± 0.01%) +9k (+ 0.00%) 313,962k 314,165k
Parse Time 1.14s (± 0.54%) 1.14s (± 0.77%) +0.00s (+ 0.35%) 1.13s 1.17s
Bind Time 0.66s (± 0.61%) 0.67s (± 1.12%) +0.01s (+ 0.91%) 0.65s 0.69s
Check Time 4.19s (± 0.40%) 4.22s (± 0.63%) +0.03s (+ 0.62%) 4.17s 4.26s
Emit Time 3.13s (± 0.61%) 3.12s (± 0.51%) -0.00s (- 0.13%) 3.09s 3.17s
Total Time 9.12s (± 0.35%) 9.15s (± 0.37%) +0.03s (+ 0.35%) 9.08s 9.21s
Angular - node (v8.9.0, x86)
Memory used 187,343k (± 0.02%) 187,360k (± 0.02%) +17k (+ 0.01%) 187,282k 187,438k
Parse Time 1.72s (± 0.80%) 1.75s (± 0.58%) +0.04s (+ 2.04%) 1.73s 1.77s
Bind Time 0.93s (± 0.74%) 0.93s (± 1.97%) -0.00s (- 0.11%) 0.89s 0.98s
Check Time 4.30s (± 0.50%) 4.30s (± 0.31%) -0.01s (- 0.19%) 4.27s 4.33s
Emit Time 5.64s (± 1.17%) 5.64s (± 1.19%) +0.00s (+ 0.02%) 5.51s 5.77s
Total Time 12.59s (± 0.73%) 12.61s (± 0.62%) +0.03s (+ 0.21%) 12.44s 12.78s
Monaco - node (v8.9.0, x86)
Memory used 200,012k (± 0.01%) 200,027k (± 0.02%) +14k (+ 0.01%) 199,920k 200,088k
Parse Time 1.48s (± 0.55%) 1.51s (± 0.84%) +0.03s (+ 1.96%) 1.48s 1.54s
Bind Time 0.72s (± 2.43%) 0.71s (± 0.73%) -0.01s (- 1.80%) 0.70s 0.72s
Check Time 4.62s (± 0.60%) 4.62s (± 0.51%) +0.00s (+ 0.02%) 4.55s 4.65s
Emit Time 3.09s (± 0.57%) 3.07s (± 0.45%) -0.01s (- 0.39%) 3.05s 3.12s
Total Time 9.90s (± 0.37%) 9.91s (± 0.29%) +0.01s (+ 0.09%) 9.85s 9.97s
TFS - node (v8.9.0, x86)
Memory used 176,085k (± 0.03%) 176,092k (± 0.02%) +8k (+ 0.00%) 176,007k 176,198k
Parse Time 1.18s (± 1.01%) 1.21s (± 1.00%) +0.02s (+ 2.03%) 1.19s 1.24s
Bind Time 0.63s (± 0.94%) 0.63s (± 0.75%) -0.00s (- 0.63%) 0.62s 0.64s
Check Time 4.04s (± 0.52%) 4.06s (± 0.89%) +0.02s (+ 0.45%) 3.99s 4.12s
Emit Time 2.75s (± 1.24%) 2.73s (± 1.22%) -0.02s (- 0.76%) 2.68s 2.83s
Total Time 8.61s (± 0.64%) 8.63s (± 0.76%) +0.02s (+ 0.20%) 8.48s 8.73s
Angular - node (v9.0.0, x64)
Memory used 330,616k (± 0.02%) 330,548k (± 0.02%) -69k (- 0.02%) 330,446k 330,693k
Parse Time 1.62s (± 0.50%) 1.63s (± 0.29%) +0.01s (+ 0.43%) 1.62s 1.64s
Bind Time 0.74s (± 1.11%) 0.74s (± 0.90%) -0.01s (- 0.67%) 0.73s 0.75s
Check Time 4.34s (± 0.48%) 4.31s (± 0.53%) -0.03s (- 0.67%) 4.25s 4.38s
Emit Time 5.73s (± 1.77%) 5.71s (± 1.77%) -0.02s (- 0.40%) 5.51s 5.91s
Total Time 12.44s (± 1.01%) 12.39s (± 0.82%) -0.05s (- 0.36%) 12.19s 12.60s
Monaco - node (v9.0.0, x64)
Memory used 358,518k (± 0.02%) 358,607k (± 0.02%) +89k (+ 0.02%) 358,411k 358,736k
Parse Time 1.28s (± 0.71%) 1.29s (± 0.53%) +0.01s (+ 1.01%) 1.28s 1.31s
Bind Time 0.85s (± 0.40%) 0.85s (± 0.70%) -0.01s (- 0.82%) 0.84s 0.86s
Check Time 4.68s (± 0.47%) 4.71s (± 0.37%) +0.02s (+ 0.49%) 4.68s 4.75s
Emit Time 3.27s (± 1.63%) 3.28s (± 0.51%) +0.01s (+ 0.40%) 3.23s 3.30s
Total Time 10.09s (± 0.73%) 10.13s (± 0.30%) +0.04s (+ 0.39%) 10.03s 10.18s
TFS - node (v9.0.0, x64)
Memory used 313,931k (± 0.02%) 313,909k (± 0.02%) -22k (- 0.01%) 313,799k 314,070k
Parse Time 1.00s (± 0.33%) 1.01s (± 0.37%) +0.01s (+ 1.50%) 1.01s 1.02s
Bind Time 0.62s (± 0.77%) 0.61s (± 0.95%) -0.00s (- 0.65%) 0.60s 0.63s
Check Time 4.23s (± 2.06%) 4.24s (± 2.17%) +0.01s (+ 0.19%) 4.12s 4.45s
Emit Time 2.97s (± 3.30%) 2.98s (± 3.20%) +0.02s (+ 0.54%) 2.82s 3.14s
Total Time 8.81s (± 0.47%) 8.85s (± 0.39%) +0.04s (+ 0.44%) 8.76s 8.91s
Angular - node (v9.0.0, x86)
Memory used 187,522k (± 0.03%) 187,512k (± 0.03%) -10k (- 0.01%) 187,396k 187,658k
Parse Time 1.54s (± 0.58%) 1.57s (± 0.86%) +0.04s (+ 2.35%) 1.55s 1.61s
Bind Time 0.86s (± 0.55%) 0.89s (± 0.77%) +0.03s (+ 2.91%) 0.87s 0.90s
Check Time 4.01s (± 0.54%) 4.05s (± 0.65%) +0.04s (+ 0.95%) 4.00s 4.13s
Emit Time 5.33s (± 0.79%) 5.39s (± 0.76%) +0.06s (+ 1.20%) 5.32s 5.53s
Total Time 11.73s (± 0.40%) 11.89s (± 0.65%) +0.16s (+ 1.36%) 11.79s 12.16s
Monaco - node (v9.0.0, x86)
Memory used 200,072k (± 0.03%) 200,057k (± 0.02%) -14k (- 0.01%) 199,996k 200,211k
Parse Time 1.31s (± 0.58%) 1.33s (± 0.60%) +0.02s (+ 1.76%) 1.31s 1.35s
Bind Time 0.64s (± 0.90%) 0.64s (± 1.41%) +0.00s (+ 0.16%) 0.63s 0.67s
Check Time 4.48s (± 0.29%) 4.48s (± 0.40%) -0.00s (- 0.04%) 4.43s 4.50s
Emit Time 2.99s (± 0.37%) 3.00s (± 0.69%) +0.01s (+ 0.20%) 2.96s 3.06s
Total Time 9.41s (± 0.20%) 9.44s (± 0.31%) +0.02s (+ 0.27%) 9.39s 9.52s
TFS - node (v9.0.0, x86)
Memory used 176,172k (± 0.02%) 176,236k (± 0.02%) +64k (+ 0.04%) 176,139k 176,319k
Parse Time 1.03s (± 1.53%) 1.04s (± 0.66%) +0.01s (+ 0.68%) 1.02s 1.05s
Bind Time 0.57s (± 1.43%) 0.58s (± 0.77%) +0.01s (+ 0.87%) 0.57s 0.59s
Check Time 3.89s (± 0.69%) 3.92s (± 0.63%) +0.03s (+ 0.77%) 3.88s 4.00s
Emit Time 2.69s (± 0.71%) 2.71s (± 0.89%) +0.02s (+ 0.63%) 2.66s 2.76s
Total Time 8.18s (± 0.62%) 8.24s (± 0.38%) +0.06s (+ 0.76%) 8.17s 8.30s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-142-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
  • node (v9.0.0, x64)
  • node (v9.0.0, x86)
Scenarios
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Angular - node (v9.0.0, x64)
  • Angular - node (v9.0.0, x86)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • Monaco - node (v9.0.0, x64)
  • Monaco - node (v9.0.0, x86)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • TFS - node (v9.0.0, x64)
  • TFS - node (v9.0.0, x86)
Benchmark Name Iterations
Current 31166 10
Baseline master 10

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rbuckton
Ron Buckton (rbuckton) force-pushed the spreadArraysES5 branch from 528601f to a451953 Compare April 29, 2019 23:45
@rbuckton
Ron Buckton (rbuckton) requested a review from Wesley Wigham (weswigham) April 30, 2019 00:10
@rbuckton
Ron Buckton (rbuckton) marked this pull request as ready for review April 30, 2019 00:10
@RyanCavanaugh Ryan Cavanaugh (RyanCavanaugh) assigned Ron Buckton (rbuckton) Apr 30, 2019
@MaxGraey

Max Graey (MaxGraey) commented May 1, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

What about speedup __spreadArrays?

var __spreadArrays = function () {
  for (var i = 0, l = 0, al = arguments.length; i < al; ++i)
    l += arguments[i].length;
  for (var ar = new Array(l), i = 0, k = 0; i < al; ++i)
    for (var j = 0, a = arguments[i], jl = a.length; j < jl; ++j, ++k)
      ar[k] = a[j];
  return ar;
};

On V8 7.4 this faster by ~3x-6x for large (> 1k) arrays.

ben

Bench link:
https://esbench.com/bench/5cc9a0f14cd7e6009ef62323

rifler reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rbuckton
Add __spreadArrays helper
66323c2
@rbuckton
Ron Buckton (rbuckton) force-pushed the spreadArraysES5 branch from a451953 to 66323c2 Compare May 2, 2019 18:11
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request May 10, 2019
Design Meeting Notes, 5/10/2019 #31350
Closed
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) added this to the TypeScript 3.6.0 milestone May 15, 2019
@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request May 29, 2019
TypeScript 3.6 Iteration Plan #31639
Closed
@rbuckton Ron Buckton (rbuckton) mentioned this pull request Jun 3, 2019
Add '__spreadArrays' helper microsoft/tslib#67
Merged
weswigham
Wesley Wigham (weswigham) reviewed Jun 10, 2019
View reviewed changes
Comment thread src/compiler/transformers/es2015.ts
}

function isPackedElement(node: Expression) {
return !isOmittedExpression(node);

@weswigham Wesley Wigham (weswigham) Jun 10, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

const innerSpreadEmpty = [1, 2, ...[...[,,,]]]

?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rbuckton Ron Buckton (rbuckton) Jun 10, 2019

Copy link
Copy Markdown
Contributor Author

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.

Works just fine.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rbuckton Ron Buckton (rbuckton) Jun 10, 2019

Copy link
Copy Markdown
Contributor Author

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.

It basically catches [...[1, 2]] and turns it into [1, 2] rather than calling the helper.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
weswigham
Wesley Wigham (weswigham) approved these changes Jun 10, 2019
View reviewed changes
@rbuckton

This comment has been minimized.

Sign in to view
@typescript-bot

This comment has been minimized.

Sign in to view
@rbuckton
Merge branch 'master' into spreadArraysES5
d6b3a11
@rbuckton

Ron Buckton (rbuckton) commented Jun 11, 2019

Copy link
Copy Markdown
Contributor Author

TypeScript Bot (@typescript-bot) test this

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 11, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at d6b3a11. You can monitor the build here. It should now contribute to this PR's status checks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rbuckton

Ron Buckton (rbuckton) commented Jun 11, 2019

Copy link
Copy Markdown
Contributor Author

Verified that the only differences in our RWC suite are expected.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rbuckton
Ron Buckton (rbuckton) merged commit 375487e into master Jun 11, 2019
@rbuckton
Ron Buckton (rbuckton) deleted the spreadArraysES5 branch June 11, 2019 21:16
@shelakel Schalk (shelakel) mentioned this pull request Sep 3, 2019
[Bug Report] TypeScript transpilation support for es5 target for IE 10/11 compatibility vuetifyjs/vuetify#8601
Closed
@KirillMetrik KirillMetrik mentioned this pull request Sep 23, 2019
__spreadArrays throws 'Cannot read property 'length' of null' when --strictNullChecks is off #33549
Closed
@devpaul Paul (devpaul) mentioned this pull request Dec 11, 2019
Update tslib to 1.10 theintern/intern#1003
Closed
@HarkaranGill HarkaranGill mentioned this pull request May 29, 2020
Typescript errors: cannot read property 'length' of undefined for spread operator, incompatibility from 3.5.1 to 3.6.3 #38855
Closed
@jameshartig James Hartig (jameshartig) mentioned this pull request Jun 7, 2023
switch to Array.from rather than spread operator IABTechLab/iabgpp-es#27
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@sheetalkamat Sheetal Nandi (sheetalkamat) sheetalkamat left review comments
@weswigham Wesley Wigham (weswigham) weswigham approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@rbuckton Ron Buckton (rbuckton)

Labels

None yet

Projects

None yet

Milestone

TypeScript 3.6.0

Development

Successfully merging this pull request may close these issues.

Spread operator is not correctly translated into JS

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@rbuckton @typescript-bot @MaxGraey @weswigham @sheetalkamat @DanielRosenwasser
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.