diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e56c0353cd3bc..eff0fdb86abc0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4526,6 +4526,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro }); checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => { + if (options.alwaysStrict === false) { + createDeprecatedDiagnostic("alwaysStrict", "false", /*useInstead*/ undefined, /*related*/ undefined); + } if (options.moduleResolution === ModuleResolutionKind.Node10) { createDeprecatedDiagnostic("moduleResolution", "node10", /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information); } diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index 7fab62c966987..336af8e0657a1 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -1600,7 +1600,7 @@ foo().hello`, }, { caption: "Set always strict false", - edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, jsonToReadableText({ compilerOptions: { strict: true, alwaysStrict: false } })), // Avoid changing 'alwaysStrict' or must re-bind + edit: sys => sys.writeFile(`/user/username/projects/myproject/tsconfig.json`, jsonToReadableText({ compilerOptions: { strict: true, alwaysStrict: false, ignoreDeprecations: "6.0" } })), // Avoid changing 'alwaysStrict' or must re-bind timeouts: sys => sys.runQueuedTimeoutCallbacks(), }, { diff --git a/tests/baselines/reference/alwaysStrictDeprecation.errors.txt b/tests/baselines/reference/alwaysStrictDeprecation.errors.txt new file mode 100644 index 0000000000000..022c45ebf2369 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecation.errors.txt @@ -0,0 +1,15 @@ +/foo/tsconfig.json(3,25): error TS5107: Option 'alwaysStrict=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + + +==== /foo/tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "alwaysStrict": false + ~~~~~ +!!! error TS5107: Option 'alwaysStrict=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error. + } + } + +==== /foo/a.ts (0 errors) ==== + const a = 1; + \ No newline at end of file diff --git a/tests/baselines/reference/alwaysStrictDeprecation.js b/tests/baselines/reference/alwaysStrictDeprecation.js new file mode 100644 index 0000000000000..c83c5c4a3cd3e --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecation.js @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/alwaysStrictDeprecation.ts] //// + +//// [a.ts] +const a = 1; + + +//// [a.js] +var a = 1; diff --git a/tests/baselines/reference/alwaysStrictDeprecation.symbols b/tests/baselines/reference/alwaysStrictDeprecation.symbols new file mode 100644 index 0000000000000..b7f2e1f27ecd7 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecation.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/alwaysStrictDeprecation.ts] //// + +=== /foo/a.ts === +const a = 1; +>a : Symbol(a, Decl(a.ts, 0, 5)) + diff --git a/tests/baselines/reference/alwaysStrictDeprecation.types b/tests/baselines/reference/alwaysStrictDeprecation.types new file mode 100644 index 0000000000000..e333b2124670c --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecation.types @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/alwaysStrictDeprecation.ts] //// + +=== /foo/a.ts === +const a = 1; +>a : 1 +> : ^ +>1 : 1 +> : ^ + diff --git a/tests/baselines/reference/alwaysStrictDeprecationSilenced.js b/tests/baselines/reference/alwaysStrictDeprecationSilenced.js new file mode 100644 index 0000000000000..f2b75001311a4 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecationSilenced.js @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] //// + +//// [a.ts] +const a = 1; + + +//// [a.js] +var a = 1; diff --git a/tests/baselines/reference/alwaysStrictDeprecationSilenced.symbols b/tests/baselines/reference/alwaysStrictDeprecationSilenced.symbols new file mode 100644 index 0000000000000..6156f09729ded --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecationSilenced.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] //// + +=== /foo/a.ts === +const a = 1; +>a : Symbol(a, Decl(a.ts, 0, 5)) + diff --git a/tests/baselines/reference/alwaysStrictDeprecationSilenced.types b/tests/baselines/reference/alwaysStrictDeprecationSilenced.types new file mode 100644 index 0000000000000..3797936457f1d --- /dev/null +++ b/tests/baselines/reference/alwaysStrictDeprecationSilenced.types @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] //// + +=== /foo/a.ts === +const a = 1; +>a : 1 +> : ^ +>1 : 1 +> : ^ + diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js b/tests/baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js index 81477c69017a4..9d90a508b614b 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js +++ b/tests/baselines/reference/tscWatch/programUpdates/updates-errors-when-strictNullChecks-changes.js @@ -140,7 +140,8 @@ Input:: { "compilerOptions": { "strict": true, - "alwaysStrict": false + "alwaysStrict": false, + "ignoreDeprecations": "6.0" } } @@ -174,6 +175,7 @@ Program root files: [ Program options: { "strict": true, "alwaysStrict": false, + "ignoreDeprecations": "6.0", "watch": true, "configFilePath": "/user/username/projects/myproject/tsconfig.json" } diff --git a/tests/cases/compiler/alwaysStrictDeprecation.ts b/tests/cases/compiler/alwaysStrictDeprecation.ts new file mode 100644 index 0000000000000..f91ef75370663 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictDeprecation.ts @@ -0,0 +1,10 @@ +// @typeScriptVersion: 6.0 +// @filename: /foo/tsconfig.json +{ + "compilerOptions": { + "alwaysStrict": false + } +} + +// @filename: /foo/a.ts +const a = 1; diff --git a/tests/cases/compiler/alwaysStrictDeprecationSilenced.ts b/tests/cases/compiler/alwaysStrictDeprecationSilenced.ts new file mode 100644 index 0000000000000..a944da4bc5907 --- /dev/null +++ b/tests/cases/compiler/alwaysStrictDeprecationSilenced.ts @@ -0,0 +1,11 @@ +// @typeScriptVersion: 6.0 +// @filename: /foo/tsconfig.json +{ + "compilerOptions": { + "alwaysStrict": false, + "ignoreDeprecations": "6.0" + } +} + +// @filename: /foo/a.ts +const a = 1;