microsoft/TypeScript

Increase default tsc --init target over time

Opened this issue ยท 1 comments

Suggestion

๐Ÿ” Search Terms

increase tsc init target es2016 default

โœ… Viability 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

โญ Suggestion

As of 2022, all releases within the last year of browsers serving >0.1% of worldwide users support at least all of ECMAScript 2019 and nearly all of ECMAScript 2020-2021, while the LTS-supported versions of Node.js support all of ECMAScript 2021. There's very little reason not to have a target at least as high as "es2019".

How about increasing the default tsc --init value for target in later TypeScript versions over time to match the highest ECMAScript version supported by all LTS Node versions? That'd be "es2021" today.

๐Ÿ“ƒ Motivating Example

Higher targets by default for consumers running tsc --init means they'll be able to use more language features as String.replaceAll by default. It's confusing to tsc --init, then not be able to use them.

๐Ÿ’ป Use Cases

Increasing default targets to emit code much cleaner in modern runtimes gives a nicer default output for new TypeScript projects. For beginners to TypeScript in particular, it makes the learning curve a little easier as they won't have to mess with configuration options to be able to use basic features.

This issue is thematically similar to but not the same as #47572 and #47573. Those issue are about changing the default compiler options when no value is specified on the CLI or in a TSConfig file. This issue is about changing the target specified when using tsc --init.

Related / duplicate in spirit: #39308