-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Deprecate alwaysStrict: false
#63089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 makes alwaysStrict effectively enabled by default, decouples it from the strict family of options, and updates the compiler and baselines to reflect stricter semantics and deprecation of alwaysStrict=false.
Changes:
- Introduces a new computed helper
getAlwaysStrictand uses it throughout the compiler (binder, transformers, strict-mode checks) instead of treatingalwaysStrictas astrictsub-flag. - Emits a deprecation diagnostic when
alwaysStrictis explicitly set tofalse, and updates command-line option metadata and strict-mode behavior accordingly. - Regenerates a large number of baselines to include
"use strict";in more outputs and to cover new(alwaysstrict=true/false)test variants and deprecation diagnostics.
Reviewed changes
Copilot reviewed 296 out of 2630 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/compiler/utilities.ts | Adds getAlwaysStrict computed option, switches strict-mode detection to it, and removes alwaysStrict from StrictOptionName. |
| src/compiler/transformers/ts.ts | Uses getAlwaysStrict to decide when to insert "use strict" and treat files as strict in the TS transformer. |
| src/compiler/transformers/module/system.ts | Uses getAlwaysStrict to determine when to ensure a "use strict" prologue in SystemJS module output. |
| src/compiler/transformers/module/module.ts | Uses getAlwaysStrict for "use strict" handling in other module emit paths. |
| src/compiler/program.ts | Adds a 6.0→7.0 deprecation diagnostic when alwaysStrict is explicitly false. |
| src/compiler/commandLineParser.ts | Updates the alwaysStrict option metadata (no longer a strictFlag, default description now true). |
| src/compiler/binder.ts | Binds files in strict mode based on getAlwaysStrict instead of getStrictOptionValue(..., "alwaysStrict"). |
| tests/baselines/reference/* | Updates many baselines to include "use strict";, new strict-mode behaviors, and new alwaysStrict deprecation diagnostics, plus adds (alwaysstrict=true/false) variants. |
jakebailey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a small handful of unit tests which seem to start testing something differently, but it's probably okay
tests/baselines/reference/tsbuildWatch/programUpdates/works-with-extended-source-files.js
Show resolved
Hide resolved
.../baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js
Outdated
Show resolved
Hide resolved
tests/baselines/reference/tscWatch/programUpdates/extended-source-files-are-watched.js
Show resolved
Hide resolved
|
@typescript-bot test top800 |
|
@jakebailey Here are the results of running the top 800 repos with tsc comparing Something interesting changed - please have a look. Details
|
Cleaned up version of #63030. Fixes #62213