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

Fix array spread with sideeffects #41523

Merged
merged 2 commits into from
Jan 6, 2021
Merged

Fix array spread with sideeffects #41523

merged 2 commits into from
Jan 6, 2021

Conversation

rbuckton
Copy link
Member

This fixes array spread when there may be side effects, using a similar approach as #31469. As a result of these changes, both the __spread and __spreadArrays helpers are now deprecated as they are no longer used. The helpers remain in emitHelpers.ts in case they are needed as part of --build.

Fixes #32959

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 13, 2020
@rbuckton
Copy link
Member Author

@sheetalkamat did you have any other feedback?

@rbuckton
Copy link
Member Author

NOTE: The tslib change for this is here: microsoft/tslib#133

@rbuckton
Copy link
Member Author

The tslib changes probably need to be merged and shipped before this is merged and goes in a nightly.

@rbuckton
Copy link
Member Author

rbuckton commented Jan 5, 2021

A new tslib has shipped. I will merge this once I resolve some new merge conflicts.

Zzzen pushed a commit to Zzzen/TypeScript that referenced this pull request Jan 16, 2021
* Fix array spread with sideeffects

* Minor cleanup, ensure multiple emit helpers for outfile tests
Gusted pushed a commit to darkreader/darkreader that referenced this pull request Mar 7, 2021
- Since Typescript 4.2 some Helpers to transpile to 4.2 are deprecated/removed. This includes __spread and __spreadArrays microsoft/TypeScript#41523.
- We heavily use the spread syntax in Dark Reader and thus need those helper functions.
- Due the upgrade of 4.2, tslib was outdated and didn't had the new helper function `__spreadArray`.
- After good hours of skimming trough the compiler and using the wrong commands to update tslib(default to 1.x). manually updating it to 2.1 which includes this new functions microsoft/tslib#133
https://github.com/microsoft/tslib/releases/tag/2.1.0
the API can be properly compiled again.
- Resolves #My personal issues with the API.
Gusted pushed a commit to darkreader/darkreader that referenced this pull request Mar 7, 2021
- Since Typescript 4.2 some Helpers to transpile to 4.2 are deprecated/removed. This includes __spread and __spreadArrays microsoft/TypeScript#41523.
- We heavily use the spread syntax in Dark Reader and thus need those helper functions.
- Due the upgrade of 4.2, tslib was outdated and didn't had the new helper function `__spreadArray`.
- After good hours of skimming trough the compiler and using the wrong commands to update tslib(default to 1.x). manually updating it to 2.1 which includes this new functions microsoft/tslib#133
https://github.com/microsoft/tslib/releases/tag/2.1.0
the API can be properly compiled again.
- Resolves #My personal issues with the API.

Note to myself: Now their are 2 versions installed `2.1.10` and `1.14.1` properly configuration setups should default to 2.1.10. But for sakes if I get into problems with this I hope I remember this note and don't waste some hours. Why `1.14.1`, I don't know. `npm --save-dev -E tslib` defaults to 1.14.1. It seems like an NPM bug `yarn add --dev -E tslib` gives the correct 2.1.10. Damn dependency hell =).
JoostK added a commit to JoostK/angular that referenced this pull request Mar 13, 2021
In TypeScript 4.2 the `__spread` and `__spreadArrays` helpers were both
replaced by the new helper function `__spreadArray` in
microsoft/TypeScript#41523. These helpers may be used in downleveled
JavaScript bundles that ngcc has to process, so ngcc has the ability to
statically detect these helpers and provide evaluation logic for them.
Because Angular is adopting support for TypeScript 4.2 it becomes
possible for libraries to be compiled by TypeScript 4.2 and thus ngcc
has to add support for the `__spreadArray` helper. The deprecated
`__spread` and `__spreadArrays` helpers are not affected by this change.

Closes angular#40394
JoostK added a commit to JoostK/angular that referenced this pull request Mar 14, 2021
This commit complements the support for the `__spreadArray` helper that
was added in microsoft/TypeScript#41523. The prior helpers `__spread`
and `__spreadArrays` used the `__read` helper internally, but the helper
is now emitted as an argument to `__spreadArray` so ngcc now needs to
support evaluating it statically. The real implementation of `__read`
reads an iterable into an array, but for ngcc's static evaluation
support it is sufficient to only deal with arrays as is. Additionally,
the optional `n` parameter is not supported as that is only emitted for
array destructuring syntax, which ngcc does not have to support.
jessicajaniuk pushed a commit to angular/angular that referenced this pull request Mar 16, 2021
…41201)

In TypeScript 4.2 the `__spread` and `__spreadArrays` helpers were both
replaced by the new helper function `__spreadArray` in
microsoft/TypeScript#41523. These helpers may be used in downleveled
JavaScript bundles that ngcc has to process, so ngcc has the ability to
statically detect these helpers and provide evaluation logic for them.
Because Angular is adopting support for TypeScript 4.2 it becomes
possible for libraries to be compiled by TypeScript 4.2 and thus ngcc
has to add support for the `__spreadArray` helper. The deprecated
`__spread` and `__spreadArrays` helpers are not affected by this change.

Closes #40394

PR Close #41201
jessicajaniuk pushed a commit to angular/angular that referenced this pull request Mar 16, 2021
This commit complements the support for the `__spreadArray` helper that
was added in microsoft/TypeScript#41523. The prior helpers `__spread`
and `__spreadArrays` used the `__read` helper internally, but the helper
is now emitted as an argument to `__spreadArray` so ngcc now needs to
support evaluating it statically. The real implementation of `__read`
reads an iterable into an array, but for ngcc's static evaluation
support it is sufficient to only deal with arrays as is. Additionally,
the optional `n` parameter is not supported as that is only emitted for
array destructuring syntax, which ngcc does not have to support.

PR Close #41201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Destructuring array polyfill isn't equivalent to new JS
5 participants