Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 3, 2025

This PR changes the default TypeScript compilation target from es5 to esnext to better align with modern JavaScript environments and "evergreen runtimes" that are now the norm.

Changes Made

  • Updated the default target fallback in src/compiler/utilities.ts from ScriptTarget.ES5 to ScriptTarget.ESNext
  • Updated the help documentation default in src/compiler/commandLineParser.ts from ScriptTarget.ES5 to ScriptTarget.ESNext
  • Accepted updated test baselines reflecting the new ESNext output instead of ES5 downleveling

Impact

When no explicit --target is specified, TypeScript will now:

  • Preserve modern JavaScript syntax (classes, arrow functions, spread operators, etc.)
  • Generate cleaner, more readable output
  • Target modern JavaScript environments by default

Before (ES5 default):

// Input
const x = [1, 2, 3];
console.log(...x);

// Output (downleveled)
var x = [1, 2, 3];
console.log.apply(console, x);

After (ESNext default):

// Input
const x = [1, 2, 3];
console.log(...x);

// Output (preserved)
const x = [1, 2, 3];
console.log(...x);

Migration

This is a breaking change. Users who need ES5 output for compatibility with older environments should explicitly specify --target es5 in their tsconfig.json:

{
  "compilerOptions": {
    "target": "es5"
  }
}

Tests with explicit // @target: es5 directives continue to work correctly and are unaffected.

Rationale

  • ES5 will be deprecated in TypeScript 6.0 and removed in 7.0 (Deprecate --target es5, make lowest target es2015 #62196)
  • Modern JavaScript environments support ESNext features natively
  • Reduces unnecessary code transformation and improves output quality
  • Aligns with TypeScript's core value proposition as "JavaScript with type syntax"

Fixes #62198.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Change default --target to esnext Change default target from ES5 to ESNext Sep 3, 2025
Copilot finished work on behalf of DanielRosenwasser September 3, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change default --target to esnext
2 participants