Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 21, 2026

Deprecates alwaysStrict: false in 6.0 (will be removed in 7.0). This enables unconditional strict mode parsing, eliminating lookahead/reparse overhead for ambiguous constructs and simplifying AST caching across projects with different flags.

Changes

Deprecation warning in src/compiler/program.ts:

if (options.alwaysStrict === false) {
    createDeprecatedDiagnostic("alwaysStrict", "false", /*useInstead*/ undefined, /*related*/ undefined);
}

User impact:

error TS5107: Option 'alwaysStrict=false' is deprecated and will stop functioning in TypeScript 7.0.
Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.

Tests:

  • alwaysStrictDeprecation.ts - verifies warning emission
  • alwaysStrictDeprecationSilenced.ts - verifies ignoreDeprecations: "6.0" silences warning
  • Updated programUpdates.ts test to add ignoreDeprecations: "6.0" to silence the deprecation warning in the updates-errors-when-strictNullChecks-changes test, allowing it to continue testing strictNullChecks changes without interference
  • Updated baseline for updates-errors-when-strictNullChecks-changes.js to reflect the silenced deprecation
Original prompt

This section details on the original issue you should resolve

<issue_title>Assume "use strict" everywhere by default</issue_title>
<issue_description>From #54500:

The alwaysStrict flag refers to inference of the "use strict"; directive. In TypeScript 6.0, all code will be assumed to be in "strict mode", which is a set of JS semantics that mostly affects syntactic corner cases around reserved words.

This lets us be faster because it's no longer necessary to look ahead or repase on constructs like

var x = await

which is legal "sloppy mode" referring to a variable named await. This also reduces the number of flags which possibly prevent sharing of source files between projects with different compiler settings.

See #61888 for RWC run; we found one codebase that used static as a parameter name.

This also lets us be a bit more efficient because our language service (and --build mode?) tries its best to reuse syntax trees for files belonging to multiple projects. When flags differ across projects, we have to sometimes cache ASTs by creating a composite key of both their paths and their projects' flags. If we can remove alwaysStrict, we can simplify our code and ensure syntax trees are shared more often. Over time, we may be able to remove all configuration flags that impact sharing.

We may need to clarify a few details here: specifically, are we removing --alwaysStrict, or just turning it on by default? If the former, that means that in 6.0 we are deprecating --alwaysStrict false.</issue_description>

Comments on the Issue (you are @copilot in this section)

@jakebailey > We may need to clarify a few details here: specifically, are we removing --alwaysStrict, or just turning it on by default? If the former, that means that in 6.0 we are deprecating --alwaysStrict false.

I believe the right answer here is that we deprecate false in 6.0, and delete it entirely in 7.0.</comment_new>
<comment_new>@jakebailey
Note that the implication here is that we unconditionally emit "use strict" in non-ESM files.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 21, 2026
Copilot AI and others added 2 commits January 21, 2026 23:16
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Assume 'use strict' everywhere by default Deprecate alwaysStrict: false in TypeScript 6.0 Jan 21, 2026
Copilot AI requested a review from RyanCavanaugh January 21, 2026 23:40
@RyanCavanaugh RyanCavanaugh marked this pull request as ready for review January 22, 2026 00:36
Copilot AI review requested due to automatic review settings January 22, 2026 00:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR deprecates the alwaysStrict: false compiler option in TypeScript 6.0, with full removal planned for 7.0. This change enables unconditional strict mode parsing, which eliminates lookahead/reparse overhead for ambiguous constructs and simplifies AST caching across projects with different compiler flags.

Changes:

  • Added deprecation warning for alwaysStrict: false in the compiler
  • Created test cases to verify deprecation warning emission and silencing behavior
  • Updated baseline for existing test affected by the deprecation warning

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/compiler/program.ts Adds deprecation check for alwaysStrict: false option
tests/cases/compiler/alwaysStrictDeprecation.ts Test case verifying deprecation warning is emitted
tests/cases/compiler/alwaysStrictDeprecationSilenced.ts Test case verifying warning can be silenced with ignoreDeprecations: "6.0"
tests/baselines/reference/alwaysStrictDeprecation.errors.txt Expected error output for deprecation warning
tests/baselines/reference/alwaysStrictDeprecation.js Expected JavaScript output for deprecation test
tests/baselines/reference/alwaysStrictDeprecation.symbols Expected symbol output for deprecation test
tests/baselines/reference/alwaysStrictDeprecation.types Expected type output for deprecation test
tests/baselines/reference/alwaysStrictDeprecationSilenced.js Expected JavaScript output when deprecation is silenced
tests/baselines/reference/alwaysStrictDeprecationSilenced.symbols Expected symbol output when deprecation is silenced
tests/baselines/reference/alwaysStrictDeprecationSilenced.types Expected type output when deprecation is silenced
tests/baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js Updated baseline now showing deprecation error instead of null check error

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot do as Jake says

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assume "use strict" everywhere by default

4 participants