镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Change default --target to latest ECMAScript version #62198

Description

The nature of TypeScript has changed in the last decade, where "evergreen runtimes" are now the norm. While it's true that there is often a rollout gap for features before they can safely be adopted, the current default target of es5 is an extreme way of serving those developers. What's more, --target es5 will no longer be supported in 7.0, and will be deprecated in 6.0 (see #62196).

While we do believe that most people do end up specifying a --target other than the default, that default is likely closer to the latest stable ECMAScript version than es5 (or even es2015) these days. And we want to encourage that.

Specifying the latest stable ECMAScript version as a target by default:

  • helps avoid some of the "cursed" behaviors that are on for older targets
  • prevents users from unnecessarily downleveling their code
  • feels less arbitrary than picking some slightly-newer target
  • reinforces the key value prop that TypeScript has focused on - that TypeScript is just JavaScript with type syntax.

There are some "dangers" here. Any code that does not specify a target will have different JavaScript output which may occasionally differ in semantics (due to semantic differences from downleveled code, things like useDefineForClassFields, or even divergences in how engines support newer features). Certain code like decorators (not currently supported in any major engine) will not work either (this last point only applied to the original proposal of targeting esnext; but now we are changing the default to the latest ECMAScript version).

Knowing how to reconfigure TypeScript for this change may be a challenge. Users will often be able to look for tsconfig.json, tsconfig.*.json, jsconfig.json, files to explicitly specify a target, but they can't just look for the string "target" anywhere because the entire problem is that it was never specified! Because TypeScript configuration can be contained in JS objects and then fed through our API, and any generated errors can be ignored, this may make upgrades particularly difficult. Users should look for calls to APIs such as createProgram, getEmitOutput, transpile, transpileModule, and transpileDeclaration.


See more discussion around 6.0 deprecations/changes at #54500.

Activity

  1. DanielRosenwasser commented on Sep 3, 2025

    @DanielRosenwasser
    MemberAuthor

    If tests break, it likely indicates that the original test file needs to have an updated // @target: ....

  2. kirkwaiblinger commented on Oct 9, 2025

    @kirkwaiblinger

    Coming over from #54500 (comment), is esnext or es2015 being proposed for the default target? This issue seems to indicate esnext but that issue seems to indicate es2015.

  3. DanielRosenwasser commented on Oct 13, 2025

    @DanielRosenwasser
    MemberAuthor

    Kirk Waiblinger (@kirkwaiblinger) the idea with that issue is that the lowest target will eventually be es2015, meaning es5 won't be supported. The original idea here is esnext would be the default.

  4. DanielRosenwasser commented on Oct 13, 2025

    @DanielRosenwasser
    MemberAuthor

    We recently had a design meeting where we decided on something a little bit less ambitious - instead of defaulting to esnext which contains stage 3 features that not every runtime will expect, we will default to the latest stable ECMAScript target. That means TypeScript 6.0 and 7.0 will default to es2025 or es2026.

    We punted on giving a specific name for this target. Instead of escurrent or something similar, we will just update the default periodically to es2025, es2026, es2027, etc.

  5. changed the title [-]Change default `--target` to `esnext`[/-] [+]Change default `--target` to latest ECMAScript version[/+] on Oct 13, 2025
  6. kirkwaiblinger commented on Oct 14, 2025

    @kirkwaiblinger

    Gotcha, that's helpful clarification! Would updating this default value be subject to the 2.5 year breaking change cadence? (I know TS 7 will ignore that cadence but interested to know what to expect going forward)

  7. RyanCavanaugh commented on Oct 14, 2025

    @RyanCavanaugh
    Member

    No, the default would be "whatever was currently current at the time of the beta" the same way esnext is a moving target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Breaking ChangeWould introduce errors in existing codeCommittedThe team has roadmapped this issueFix AvailableA PR has been opened for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions