Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

feat(typescript): allow downlevelIteration in Angular 5 #239

Closed
wants to merge 1 commit into from
Closed

feat(typescript): allow downlevelIteration in Angular 5 #239

wants to merge 1 commit into from

Conversation

cyrilletuzi
Copy link
Contributor

@cyrilletuzi cyrilletuzi commented Oct 26, 2017

Before TypeScript 2.3, when targeting ES5 (which is the case in Angular CLI), for ... of was limited to Array. Meaning it's not possible to iterate easily on new iterables like Map.

It's now possible since TypeScript 2.3, but requires the flag downlevelIteration. As Angular 5 requires TS >= 2.4, it's OK to enable this flag by default.

@hansl @filipesilva @Brocco I don't know how to manage the option to be Angular >= 5 (or TypeScript >= 2.3) only in schematics. Is there a variable available for that, or is there another system to separate between Angular versions (as I suppose similar cases will happen) ?

@trotyl
Copy link
Contributor

trotyl commented Oct 26, 2017

downlevelIteration would cause severe performance issue in generated file size, it's not suggested in TypeScript itself and has been manually disabled in Zone.js.

@cyrilletuzi
Copy link
Contributor Author

cyrilletuzi commented Oct 26, 2017

it's not suggested in TypeScript itself

Can you provide a link about that ? Official release notes don't say it's not suggested.

About performance, the zone.js issue just says it produces a bigger bundle, not that it has performance impact. But :

  • the size issue can be tempered by tslib --importHelpers, which I think Angular CLI is using ;
  • it would be an issue just for ES5 bundles, ES2015 bundles (which is more and more becoming the new default) are not affected (but on contrary, they are currently affected by not being able to do what is possible in ES6 because of the current config).

And it's not the same for a complex library like zone.js to not add unnecessary tools for a few lines, and for a full app development to limit and complexify the dev experience for all a team.

@trotyl
Copy link
Contributor

trotyl commented Oct 26, 2017

From microsoft/TypeScript#3164 (comment). Not sure if it's an official point.

@cyrilletuzi
Copy link
Contributor Author

Closing as forEach is enough for Map and Set and DOM iteration irrelevant in Angular

@cyrilletuzi cyrilletuzi closed this Dec 7, 2017
@cyrilletuzi cyrilletuzi deleted the patch-3 branch December 7, 2017 21:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants