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>
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 23, 2026

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/63030/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"
  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,387 50,387 ~ ~ ~ p=1.000 n=6
Memory used 193,754k (± 0.94%) 194,389k (± 1.01%) ~ 192,568k 196,217k p=0.378 n=6
Parse Time 1.30s (± 0.42%) 1.30s (± 0.49%) ~ 1.29s 1.31s p=0.201 n=6
Bind Time 0.76s 0.76s ~ ~ ~ p=1.000 n=6
Check Time 9.86s (± 0.28%) 9.89s (± 0.21%) ~ 9.86s 9.91s p=0.073 n=6
Emit Time 2.74s (± 0.91%) 2.74s (± 0.60%) ~ 2.71s 2.76s p=0.935 n=6
Total Time 14.66s (± 0.30%) 14.69s (± 0.21%) ~ 14.65s 14.74s p=0.146 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 955,823 955,823 ~ ~ ~ p=1.000 n=6
Types 415,853 415,853 ~ ~ ~ p=1.000 n=6
Memory used 1,253,904k (± 0.00%) 1,253,899k (± 0.00%) ~ 1,253,847k 1,253,941k p=0.810 n=6
Parse Time 6.54s (± 0.46%) 6.53s (± 0.43%) ~ 6.51s 6.58s p=0.366 n=6
Bind Time 1.96s 1.96s (± 0.68%) ~ 1.94s 1.98s p=0.599 n=6
Check Time 32.41s (± 0.32%) 32.47s (± 0.27%) ~ 32.32s 32.55s p=0.297 n=6
Emit Time 15.00s (± 0.33%) 14.98s (± 0.33%) ~ 14.91s 15.04s p=0.469 n=6
Total Time 55.91s (± 0.25%) 55.94s (± 0.13%) ~ 55.84s 56.05s p=0.688 n=6
mui-docs - node (v18.15.0, x64)
Errors 11,439 11,439 ~ ~ ~ p=1.000 n=6
Symbols 2,700,258 2,700,258 ~ ~ ~ p=1.000 n=6
Types 930,444 930,444 ~ ~ ~ p=1.000 n=6
Memory used 3,036,168k (± 0.00%) 3,036,130k (± 0.00%) ~ 3,035,985k 3,036,245k p=0.575 n=6
Parse Time 8.59s (± 0.23%) 8.59s (± 0.11%) ~ 8.58s 8.61s p=1.000 n=6
Bind Time 2.30s (± 0.45%) 2.30s (± 0.22%) ~ 2.30s 2.31s p=0.928 n=6
Check Time 92.72s (± 0.74%) 93.13s (± 0.32%) ~ 92.77s 93.44s p=0.229 n=6
Emit Time 0.31s (± 2.41%) 0.31s (± 3.19%) ~ 0.30s 0.32s p=0.554 n=6
Total Time 103.93s (± 0.68%) 104.34s (± 0.29%) ~ 103.96s 104.66s p=0.296 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,447 1,252,449 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 259,946 259,946 ~ ~ ~ p=1.000 n=6
Memory used 2,387,987k (± 0.03%) 2,508,754k (±11.83%) ~ 2,387,113k 3,115,333k p=0.689 n=6
Parse Time 5.13s (± 0.43%) 5.16s (± 1.25%) ~ 5.10s 5.28s p=0.294 n=6
Bind Time 1.87s (± 0.63%) 1.85s (± 0.93%) ~ 1.82s 1.87s p=0.050 n=6
Check Time 35.47s (± 0.22%) 35.60s (± 0.39%) ~ 35.39s 35.81s p=0.149 n=6
Emit Time 2.97s (± 2.94%) 3.01s (± 1.01%) ~ 2.96s 3.04s p=0.336 n=6
Total Time 45.45s (± 0.24%) 45.66s (± 0.34%) +0.21s (+ 0.46%) 45.47s 45.84s p=0.045 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,447 1,252,449 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 259,946 259,946 ~ ~ ~ p=1.000 n=6
Memory used 2,941,345k (±12.73%) 3,183,461k (± 0.02%) ~ 3,182,697k 3,184,290k p=0.378 n=6
Parse Time 6.79s (± 1.75%) 6.78s (± 0.68%) ~ 6.71s 6.84s p=0.575 n=6
Bind Time 2.27s (± 0.71%) 2.26s (± 1.13%) ~ 2.23s 2.30s p=0.575 n=6
Check Time 42.93s (± 0.31%) 43.06s (± 0.22%) ~ 42.96s 43.19s p=0.093 n=6
Emit Time 3.52s (± 2.07%) 3.48s (± 1.60%) ~ 3.41s 3.54s p=0.575 n=6
Total Time 55.51s (± 0.42%) 55.58s (± 0.20%) ~ 55.43s 55.70s p=0.688 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 264,690 264,690 ~ ~ ~ p=1.000 n=6
Types 104,079 104,079 ~ ~ ~ p=1.000 n=6
Memory used 443,079k (± 0.01%) 443,091k (± 0.02%) ~ 442,982k 443,212k p=0.810 n=6
Parse Time 3.51s (± 0.50%) 3.52s (± 1.05%) ~ 3.49s 3.59s p=0.743 n=6
Bind Time 1.39s (± 1.66%) 1.37s (± 0.59%) ~ 1.36s 1.38s p=0.183 n=6
Check Time 19.14s (± 0.35%) 19.16s (± 0.43%) ~ 19.08s 19.30s p=0.573 n=6
Emit Time 1.55s (± 0.68%) 1.55s (± 0.67%) ~ 1.53s 1.56s p=0.801 n=6
Total Time 25.59s (± 0.21%) 25.59s (± 0.39%) ~ 25.48s 25.77s p=1.000 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 73 73 ~ ~ ~ p=1.000 n=6
Symbols 225,493 225,493 ~ ~ ~ p=1.000 n=6
Types 94,373 94,373 ~ ~ ~ p=1.000 n=6
Memory used 369,941k (± 0.05%) 370,007k (± 0.08%) ~ 369,735k 370,374k p=0.689 n=6
Parse Time 2.81s (± 0.74%) 2.83s (± 0.79%) ~ 2.79s 2.85s p=0.190 n=6
Bind Time 1.66s (± 1.17%) 1.65s (± 0.49%) ~ 1.64s 1.66s p=0.869 n=6
Check Time 16.64s (± 0.27%) 16.63s (± 0.45%) ~ 16.52s 16.71s p=0.936 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 21.11s (± 0.16%) 21.11s (± 0.38%) ~ 21.02s 21.23s p=1.000 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,157,470 4,157,470 ~ ~ ~ p=1.000 n=6
Types 1,316,480 1,316,480 ~ ~ ~ p=1.000 n=6
Memory used 3,950,721k (± 0.00%) 3,950,611k (± 0.00%) ~ 3,950,429k 3,950,806k p=0.298 n=6
Parse Time 16.04s (± 0.60%) 16.10s (± 0.73%) ~ 15.96s 16.26s p=0.335 n=6
Bind Time 5.52s (± 2.44%) 5.57s (± 3.11%) ~ 5.33s 5.72s p=1.000 n=6
Check Time 115.72s (± 2.72%) 116.09s (± 3.16%) ~ 112.62s 119.93s p=0.575 n=6
Emit Time 48.59s (± 4.85%) 53.62s (±11.51%) ~ 47.00s 63.72s p=0.173 n=6
Total Time 185.87s (± 2.95%) 191.38s (± 3.94%) ~ 181.56s 197.90s p=0.230 n=6
webpack - node (v18.15.0, x64)
Errors 41 41 ~ ~ ~ p=1.000 n=6
Symbols 383,986 383,986 ~ ~ ~ p=1.000 n=6
Types 167,978 167,978 ~ ~ ~ p=1.000 n=6
Memory used 543,826k (± 0.03%) 543,688k (± 0.02%) ~ 543,511k 543,898k p=0.173 n=6
Parse Time 4.63s (± 0.75%) 4.63s (± 0.42%) ~ 4.60s 4.65s p=1.000 n=6
Bind Time 2.04s (± 0.91%) 2.03s (± 1.06%) ~ 2.00s 2.06s p=0.871 n=6
Check Time 23.68s (± 1.68%) 23.82s (± 1.30%) ~ 23.24s 24.11s p=0.689 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 30.34s (± 1.31%) 30.48s (± 1.02%) ~ 29.89s 30.75s p=0.688 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 729,756 729,756 ~ ~ ~ p=1.000 n=6
Types 218,510 218,510 ~ ~ ~ p=1.000 n=6
Memory used 633,761k (± 0.01%) 633,713k (± 0.00%) ~ 633,685k 633,742k p=0.066 n=6
Parse Time 4.56s (± 0.39%) 4.58s (± 0.78%) ~ 4.52s 4.62s p=0.226 n=6
Bind Time 1.48s (± 0.82%) 1.48s (± 0.35%) ~ 1.48s 1.49s p=1.000 n=6
Check Time 22.02s (± 0.15%) 22.10s (± 0.30%) +0.08s (+ 0.35%) 22.03s 22.19s p=0.037 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.07s (± 0.08%) 28.17s (± 0.20%) +0.10s (+ 0.34%) 28.12s 28.26s p=0.005 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/63030/merge:

Everything looks good!

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