[feat] Allow use of downlevelIteration on es2015 or greater
See original GitHub issueSearch Terms
downlevelIteration es2015 es6
Suggestion
A new flag or way to enable downlevelIteration
when targeting es2015 or greater
Maybe forceDownlevelIteration
?
Use Cases
for .. of
is slow: https://jsperf.com/for-vs-forof
This request comes from my recent work in Nodejs where you want to use higher targets for better performance from the runtime but have to replace for .. of
with for
due to it’s inefficiencies.
Devs shouldn’t be forced to write less ergonomic code for performance reasons when TypeScript could simply do it for you.
An example of having to refactor due to increasing the language target: https://github.com/angular/angular/pull/24534
Examples
N/A
Checklist
My suggestion meets these guidelines:
- This wouldn’t be a breaking change in existing TypeScript / JavaScript code
- This wouldn’t change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn’t a runtime feature (e.g. new expression-level syntax)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10 (5 by maintainers)
Top Results From Across the Web
[feat] Allow use of downlevelIteration on es2015 or greater
Search Terms downlevelIteration es2015 es6 Suggestion A new flag or way to enable downlevelIteration when targeting es2015 or greater Maybe ...
Read more >TSConfig Option: downlevelIteration - TypeScript
downlevelIteration allows for these iteration primitives to be used more accurately in ES5 environments if a Symbol.iterator implementation is present.
Read more >Downlevel Iteration for ES3/ES5 in TypeScript - Marius Schulz
TypeScript 2.3 introduced a new --downlevelIteration flag that adds ... our code only uses ES2015 syntax and nothing specific to TypeScript.
Read more >Why `downlevelIteration` is not on by default? - Stack Overflow
--downlevelIteration allows for these iteration primitives to be used more accurately in ES5 environments if a Symbol.iterator ...
Read more >tsconfig.json · master · Daniel Brada / Vue perfectionist setup ...
Visit https://aka.ms/tsconfig.json to read more about this file */ ... "allowJs": true, /* Allow javascript files to be compiled. */.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kitsonk Agreed, but as I pointed out above, not everyone knows that most of the other methods of iteration are slow compared to
for
.Also writing
for
loops are much less ergonomic compared tofor ... of
, I personally would like to use the newer language features without feeling hindered by the performance concerns that go with it.Sounds to me that what you want is a TSLint rule or something along those lines. It’s not TS responsibility to downlevel language features that are natively supported by the target. That goes against its philosophy, surely.