Skip to content

Commit 6a17477

Browse files
Add deprecation warning for alwaysStrict: false
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
1 parent 7858bec commit 6a17477

10 files changed

+85
-0
lines changed

src/compiler/program.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4526,6 +4526,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
45264526
});
45274527

45284528
checkDeprecations("6.0", "7.0", createDiagnostic, createDeprecatedDiagnostic => {
4529+
if (options.alwaysStrict === false) {
4530+
createDeprecatedDiagnostic("alwaysStrict", "false", /*useInstead*/ undefined, /*related*/ undefined);
4531+
}
45294532
if (options.moduleResolution === ModuleResolutionKind.Node10) {
45304533
createDeprecatedDiagnostic("moduleResolution", "node10", /*useInstead*/ undefined, Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information);
45314534
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/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.
2+
3+
4+
==== /foo/tsconfig.json (1 errors) ====
5+
{
6+
"compilerOptions": {
7+
"alwaysStrict": false
8+
~~~~~
9+
!!! error TS5107: Option 'alwaysStrict=false' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
10+
}
11+
}
12+
13+
==== /foo/a.ts (0 errors) ====
14+
const a = 1;
15+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecation.ts] ////
2+
3+
//// [a.ts]
4+
const a = 1;
5+
6+
7+
//// [a.js]
8+
var a = 1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecation.ts] ////
2+
3+
=== /foo/a.ts ===
4+
const a = 1;
5+
>a : Symbol(a, Decl(a.ts, 0, 5))
6+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecation.ts] ////
2+
3+
=== /foo/a.ts ===
4+
const a = 1;
5+
>a : 1
6+
> : ^
7+
>1 : 1
8+
> : ^
9+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] ////
2+
3+
//// [a.ts]
4+
const a = 1;
5+
6+
7+
//// [a.js]
8+
var a = 1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] ////
2+
3+
=== /foo/a.ts ===
4+
const a = 1;
5+
>a : Symbol(a, Decl(a.ts, 0, 5))
6+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [tests/cases/compiler/alwaysStrictDeprecationSilenced.ts] ////
2+
3+
=== /foo/a.ts ===
4+
const a = 1;
5+
>a : 1
6+
> : ^
7+
>1 : 1
8+
> : ^
9+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @typeScriptVersion: 6.0
2+
// @filename: /foo/tsconfig.json
3+
{
4+
"compilerOptions": {
5+
"alwaysStrict": false
6+
}
7+
}
8+
9+
// @filename: /foo/a.ts
10+
const a = 1;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @typeScriptVersion: 6.0
2+
// @filename: /foo/tsconfig.json
3+
{
4+
"compilerOptions": {
5+
"alwaysStrict": false,
6+
"ignoreDeprecations": "6.0"
7+
}
8+
}
9+
10+
// @filename: /foo/a.ts
11+
const a = 1;

0 commit comments

Comments
 (0)