question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feat] Allow use of downlevelIteration on es2015 or greater

See original GitHub issue

Search 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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Toxicablecommented, Jun 19, 2018

@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 to for ... of, I personally would like to use the newer language features without feeling hindered by the performance concerns that go with it.

0reactions
alfaprojectcommented, Mar 4, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found