Repository navigation
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
DanielRosenwasser commentedon Sep 3, 2025
If tests break, it likely indicates that the original test file needs to have an updated
// @target: ....kirkwaiblinger commentedon Oct 9, 2025
Coming over from #54500 (comment), is
esnextores2015being proposed for the default target? This issue seems to indicateesnextbut that issue seems to indicatees2015.DanielRosenwasser commentedon Oct 13, 2025
Kirk Waiblinger (@kirkwaiblinger) the idea with that issue is that the lowest target will eventually be
es2015, meaninges5won't be supported. The original idea here isesnextwould be the default.DanielRosenwasser commentedon Oct 13, 2025
We recently had a design meeting where we decided on something a little bit less ambitious - instead of defaulting to
esnextwhich 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 toes2025ores2026.We punted on giving a specific name for this target. Instead of
escurrentor something similar, we will just update the default periodically toes2025,es2026,es2027, etc.[-]Change default `--target` to `esnext`[/-][+]Change default `--target` to latest ECMAScript version[/+]kirkwaiblinger commentedon Oct 14, 2025
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)
RyanCavanaugh commentedon Oct 14, 2025
No, the default would be "whatever was currently current at the time of the beta" the same way
esnextis a moving target