Skip to content

Increase default tsc --init target over timeΒ #49206

Open
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions