Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit904e7dd

Browse files
EnablenoUncheckedSideEffectImports by default (#62443)
1 parent233f392 commit904e7dd

File tree

40 files changed

+329
-50
lines changed

40 files changed

+329
-50
lines changed

‎src/compiler/checker.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
15311531
var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
15321532
var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
15331533
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
1534-
var noUncheckedSideEffectImports =!!compilerOptions.noUncheckedSideEffectImports;
1534+
var noUncheckedSideEffectImports = compilerOptions.noUncheckedSideEffectImports !== false;
15351535

15361536
var checkBinaryExpression = createCheckBinaryExpression();
15371537
var emitResolver = createResolver();
@@ -4684,9 +4684,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
46844684
}
46854685
}
46864686

4687-
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean): Symbol | undefined {
4687+
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean, errorMessage?: DiagnosticMessage): Symbol | undefined {
46884688
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
4689-
consterrorMessage = isClassic ?
4689+
errorMessage??= isClassic ?
46904690
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
46914691
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
46924692
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors);
@@ -48516,7 +48516,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4851648516
}
4851748517
}
4851848518
else if (noUncheckedSideEffectImports && !importClause) {
48519-
void resolveExternalModuleName(node, node.moduleSpecifier);
48519+
void resolveExternalModuleName(node, node.moduleSpecifier, /*ignoreErrors*/ undefined, Diagnostics.Cannot_find_module_or_type_declarations_for_side_effect_import_of_0);
4852048520
}
4852148521
}
4852248522
checkImportAttributes(node);

‎src/compiler/commandLineParser.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
12431243
affectsBuildInfo:true,
12441244
category:Diagnostics.Modules,
12451245
description:Diagnostics.Check_side_effect_imports,
1246-
defaultValueDescription:false,
1246+
defaultValueDescription:true,
12471247
},
12481248

12491249
// Source Maps

‎src/compiler/diagnosticMessages.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,6 +4007,10 @@
40074007
"category":"Error",
40084008
"code":2881
40094009
},
4010+
"Cannot find module or type declarations for side-effect import of '{0}'.": {
4011+
"category":"Error",
4012+
"code":2882
4013+
},
40104014

40114015
"Import declaration '{0}' is using private name '{1}'.": {
40124016
"category":"Error",

‎tests/baselines/reference/amdDependencyCommentName4.errors.txt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
amdDependencyCommentName4.ts(6,8): error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule1'.
12
amdDependencyCommentName4.ts(8,21): error TS2792: Cannot find module 'aliasedModule1'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
23
amdDependencyCommentName4.ts(11,26): error TS2792: Cannot find module 'aliasedModule2'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
34
amdDependencyCommentName4.ts(14,15): error TS2792: Cannot find module 'aliasedModule3'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
45
amdDependencyCommentName4.ts(17,21): error TS2792: Cannot find module 'aliasedModule4'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
6+
amdDependencyCommentName4.ts(20,8): error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule2'.
57

68

7-
==== amdDependencyCommentName4.ts (4 errors) ====
9+
==== amdDependencyCommentName4.ts (6 errors) ====
810
///<amd-dependency path='aliasedModule5' name='n1'/>
911
///<amd-dependency path='unaliasedModule3'/>
1012
///<amd-dependency path='aliasedModule6' name='n2'/>
1113
///<amd-dependency path='unaliasedModule4'/>
1214

1315
import "unaliasedModule1";
16+
~~~~~~~~~~~~~~~~~~
17+
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule1'.
1418

1519
import r1 = require("aliasedModule1");
1620
~~~~~~~~~~~~~~~~
@@ -32,4 +36,6 @@ amdDependencyCommentName4.ts(17,21): error TS2792: Cannot find module 'aliasedMo
3236
!!! error TS2792: Cannot find module 'aliasedModule4'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
3337
ns;
3438

35-
import "unaliasedModule2";
39+
import "unaliasedModule2";
40+
~~~~~~~~~~~~~~~~~~
41+
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule2'.

‎tests/baselines/reference/autoAccessorDisallowedModifiers(target=es2017).errors.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ autoAccessorDisallowedModifiers.ts(31,1): error TS1275: 'accessor' modifier can
2323
autoAccessorDisallowedModifiers.ts(32,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2424
autoAccessorDisallowedModifiers.ts(33,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2525
autoAccessorDisallowedModifiers.ts(34,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
26+
autoAccessorDisallowedModifiers.ts(34,17): error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
2627
autoAccessorDisallowedModifiers.ts(35,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2728
autoAccessorDisallowedModifiers.ts(35,25): error TS2792: Cannot find module 'x'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
2829
autoAccessorDisallowedModifiers.ts(36,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2930
autoAccessorDisallowedModifiers.ts(37,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
3031
autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
3132

3233

33-
==== autoAccessorDisallowedModifiers.ts (30 errors) ====
34+
==== autoAccessorDisallowedModifiers.ts (31 errors) ====
3435
abstract class C1 {
3536
accessor accessor a: any;
3637
~~~~~~~~
@@ -115,6 +116,8 @@ autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can
115116
accessor import "x";
116117
~~~~~~~~
117118
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
119+
~~~
120+
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
118121
accessor import {} from "x";
119122
~~~~~~~~
120123
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.

‎tests/baselines/reference/autoAccessorDisallowedModifiers(target=esnext).errors.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ autoAccessorDisallowedModifiers.ts(31,1): error TS1275: 'accessor' modifier can
2323
autoAccessorDisallowedModifiers.ts(32,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2424
autoAccessorDisallowedModifiers.ts(33,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2525
autoAccessorDisallowedModifiers.ts(34,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
26+
autoAccessorDisallowedModifiers.ts(34,17): error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
2627
autoAccessorDisallowedModifiers.ts(35,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2728
autoAccessorDisallowedModifiers.ts(35,25): error TS2792: Cannot find module 'x'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
2829
autoAccessorDisallowedModifiers.ts(36,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
2930
autoAccessorDisallowedModifiers.ts(37,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
3031
autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
3132

3233

33-
==== autoAccessorDisallowedModifiers.ts (30 errors) ====
34+
==== autoAccessorDisallowedModifiers.ts (31 errors) ====
3435
abstract class C1 {
3536
accessor accessor a: any;
3637
~~~~~~~~
@@ -115,6 +116,8 @@ autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can
115116
accessor import "x";
116117
~~~~~~~~
117118
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
119+
~~~
120+
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
118121
accessor import {} from "x";
119122
~~~~~~~~
120123
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.

‎tests/baselines/reference/checkExportsObjectAssignPrototypeProperty.errors.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
validator.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './'.
12
validator.ts(19,4): error TS2540: Cannot assign to 'readonlyProp' because it is a read-only property.
23
validator.ts(20,4): error TS2540: Cannot assign to 'readonlyAccessor' because it is a read-only property.
34
validator.ts(21,1): error TS2322: Type 'string' is not assignable to type 'number'.
45
validator.ts(22,1): error TS2322: Type 'string' is not assignable to type 'number'.
56
validator.ts(23,1): error TS2322: Type 'number' is not assignable to type 'string'.
67

78

8-
==== validator.ts (5 errors) ====
9+
==== validator.ts (6 errors) ====
910
import "./";
11+
~~~~
12+
!!! error TS2882: Cannot find module or type declarations for side-effect import of './'.
1013

1114
import Person = require("./mod1");
1215

‎tests/baselines/reference/emit(jsx=preserve).errors.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ main.ts(3,16): error TS2307: Cannot find module '../foo.mts' or its correspondin
33
main.ts(4,16): error TS2307: Cannot find module '../../foo.cts' or its corresponding type declarations.
44
main.ts(5,16): error TS2307: Cannot find module './foo.tsx' or its corresponding type declarations.
55
main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
6+
main.ts(7,8): error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
67
main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
78
main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
89
main.ts(11,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
@@ -23,7 +24,7 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
2324
==== globals.d.ts (0 errors) ====
2425
declare function require(module: string): any;
2526

26-
==== main.ts (10 errors) ====
27+
==== main.ts (11 errors) ====
2728
// Rewrite
2829
import {} from "./foo.ts";
2930
~~~~~~~~~~
@@ -41,6 +42,8 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
4142
~~~~~~~~~~
4243
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
4344
import "./foo.ts";
45+
~~~~~~~~~~
46+
!!! error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
4447
export * from "./foo.ts";
4548
~~~~~~~~~~
4649
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.

‎tests/baselines/reference/emit(jsx=react).errors.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ main.ts(3,16): error TS2307: Cannot find module '../foo.mts' or its correspondin
33
main.ts(4,16): error TS2307: Cannot find module '../../foo.cts' or its corresponding type declarations.
44
main.ts(5,16): error TS2307: Cannot find module './foo.tsx' or its corresponding type declarations.
55
main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
6+
main.ts(7,8): error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
67
main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
78
main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
89
main.ts(11,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
@@ -23,7 +24,7 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
2324
==== globals.d.ts (0 errors) ====
2425
declare function require(module: string): any;
2526

26-
==== main.ts (10 errors) ====
27+
==== main.ts (11 errors) ====
2728
// Rewrite
2829
import {} from "./foo.ts";
2930
~~~~~~~~~~
@@ -41,6 +42,8 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
4142
~~~~~~~~~~
4243
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
4344
import "./foo.ts";
45+
~~~~~~~~~~
46+
!!! error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
4447
export * from "./foo.ts";
4548
~~~~~~~~~~
4649
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
es6ImportWithoutFromClauseInEs5_1.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'es6ImportWithoutFromClauseInEs5_0'.
2+
3+
4+
==== es6ImportWithoutFromClauseInEs5_0.ts (0 errors) ====
5+
export var a = 10;
6+
7+
==== es6ImportWithoutFromClauseInEs5_1.ts (1 errors) ====
8+
import "es6ImportWithoutFromClauseInEs5_0";
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'es6ImportWithoutFromClauseInEs5_0'.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp