-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
Overview
With TypeScript 7.0, we have no plans to port over our downleveling from ES2015/ES6 to ES5. ECMAScript 5 was a stable and broad target that seemed like the safest option years ago, but the need to support ES5 environments has shrunk dramatically. Additionally, there is quite a bit of complexity in supporting the transformation of generators.
ES2015 is 10 years old at this point, and is a reasonable lowest target.
Because TypeScript 7.0 will not support --target es5
, TypeScript 6.0 will be deprecating it.
That means that TypeScript 6.0 will allow you to use --target es5
, but you will receive an error that can only be silenced via ignoreDeprecations
.
Users who do rely on ES5 runtimes will be able to use older versions of TypeScript for its downlevel compilation capabilities, Babel, or another compiler. But we do encourage teams to re-evaluate whether they need to support ES5 runtimes.
lib
, lib.d.ts
, and the DOM libraries
Today, lib.d.ts
(TypeScript's nickname for its family of built-in library files) is broken up into many files like lib.es5.d.ts
, etc.
Changing the default minimum target means that we need to reconsider what default library files get included based on the target, and how lib
continues to function. One complication here is the interplay between whether dom
includes dom.iterable
, or vice versa.
Most recently, our thinking here is:
es5
continues to exist as alib
target so that it is not an error to reference- the
es2015
lib
options automatically includeses5
- the contents of
dom.iterable
effectively gets included as part of usingdom
dom.iterable
will become empty so that it is not an error to reference
Some experimentation around this is taking place at #62025
--downlevelIteration
--downlevelIteration
controls whether or not the JS "iterator protocol" is respected (i.e. using Symbol.iterator
and the like) by constructs like array spreads, for
/of
loops, etc. Otherwise, TypeScript would downlevel these constructs in a naive way (e.g. concat
and for
loops with counter variables).
But this functionality is just assumed to work in ECMAScript 2015, and the flag does nothing in --target es2015
. We may want to issue an error message if this flag is specified in conjunction with any newer target, but it seems unnecessary to do so.
See more deprecation discussions at #54500.