Enable noUncheckedSideEffectImports by default (#62443)

This commit is contained in:
Ryan Cavanaugh
2025-09-22 12:06:04 -07:00
committed by GitHub
parent 233f392d67
commit 904e7dd97d
40 changed files with 329 additions and 50 deletions
+4 -4
View File
@@ -1531,7 +1531,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
var noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
var useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables");
var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes;
var noUncheckedSideEffectImports = !!compilerOptions.noUncheckedSideEffectImports;
var noUncheckedSideEffectImports = compilerOptions.noUncheckedSideEffectImports !== false;
var checkBinaryExpression = createCheckBinaryExpression();
var emitResolver = createResolver();
@@ -4684,9 +4684,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean): Symbol | undefined {
function resolveExternalModuleName(location: Node, moduleReferenceExpression: Expression, ignoreErrors?: boolean, errorMessage?: DiagnosticMessage): Symbol | undefined {
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
const errorMessage = isClassic ?
errorMessage ??= isClassic ?
Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage, ignoreErrors);
@@ -48516,7 +48516,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
}
else if (noUncheckedSideEffectImports && !importClause) {
void resolveExternalModuleName(node, node.moduleSpecifier);
void resolveExternalModuleName(node, node.moduleSpecifier, /*ignoreErrors*/ undefined, Diagnostics.Cannot_find_module_or_type_declarations_for_side_effect_import_of_0);
}
}
checkImportAttributes(node);
+1 -1
View File
@@ -1243,7 +1243,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
affectsBuildInfo: true,
category: Diagnostics.Modules,
description: Diagnostics.Check_side_effect_imports,
defaultValueDescription: false,
defaultValueDescription: true,
},
// Source Maps
+4
View File
@@ -4007,6 +4007,10 @@
"category": "Error",
"code": 2881
},
"Cannot find module or type declarations for side-effect import of '{0}'.": {
"category": "Error",
"code": 2882
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -1,16 +1,20 @@
amdDependencyCommentName4.ts(6,8): error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule1'.
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?
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?
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?
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?
amdDependencyCommentName4.ts(20,8): error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule2'.
==== amdDependencyCommentName4.ts (4 errors) ====
==== amdDependencyCommentName4.ts (6 errors) ====
///<amd-dependency path='aliasedModule5' name='n1'/>
///<amd-dependency path='unaliasedModule3'/>
///<amd-dependency path='aliasedModule6' name='n2'/>
///<amd-dependency path='unaliasedModule4'/>
import "unaliasedModule1";
~~~~~~~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule1'.
import r1 = require("aliasedModule1");
~~~~~~~~~~~~~~~~
@@ -32,4 +36,6 @@ amdDependencyCommentName4.ts(17,21): error TS2792: Cannot find module 'aliasedMo
!!! error TS2792: Cannot find module 'aliasedModule4'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
ns;
import "unaliasedModule2";
import "unaliasedModule2";
~~~~~~~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'unaliasedModule2'.
@@ -23,6 +23,7 @@ autoAccessorDisallowedModifiers.ts(31,1): error TS1275: 'accessor' modifier can
autoAccessorDisallowedModifiers.ts(32,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(33,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(34,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(34,17): error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
autoAccessorDisallowedModifiers.ts(35,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
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?
autoAccessorDisallowedModifiers.ts(36,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
@@ -30,7 +31,7 @@ autoAccessorDisallowedModifiers.ts(37,1): error TS1275: 'accessor' modifier can
autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
==== autoAccessorDisallowedModifiers.ts (30 errors) ====
==== autoAccessorDisallowedModifiers.ts (31 errors) ====
abstract class C1 {
accessor accessor a: any;
~~~~~~~~
@@ -115,6 +116,8 @@ autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can
accessor import "x";
~~~~~~~~
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
accessor import {} from "x";
~~~~~~~~
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
@@ -23,6 +23,7 @@ autoAccessorDisallowedModifiers.ts(31,1): error TS1275: 'accessor' modifier can
autoAccessorDisallowedModifiers.ts(32,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(33,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(34,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
autoAccessorDisallowedModifiers.ts(34,17): error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
autoAccessorDisallowedModifiers.ts(35,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
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?
autoAccessorDisallowedModifiers.ts(36,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
@@ -30,7 +31,7 @@ autoAccessorDisallowedModifiers.ts(37,1): error TS1275: 'accessor' modifier can
autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can only appear on a property declaration.
==== autoAccessorDisallowedModifiers.ts (30 errors) ====
==== autoAccessorDisallowedModifiers.ts (31 errors) ====
abstract class C1 {
accessor accessor a: any;
~~~~~~~~
@@ -115,6 +116,8 @@ autoAccessorDisallowedModifiers.ts(38,1): error TS1275: 'accessor' modifier can
accessor import "x";
~~~~~~~~
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'x'.
accessor import {} from "x";
~~~~~~~~
!!! error TS1275: 'accessor' modifier can only appear on a property declaration.
@@ -1,3 +1,4 @@
validator.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './'.
validator.ts(19,4): error TS2540: Cannot assign to 'readonlyProp' because it is a read-only property.
validator.ts(20,4): error TS2540: Cannot assign to 'readonlyAccessor' because it is a read-only property.
validator.ts(21,1): error TS2322: Type 'string' is not assignable to type 'number'.
@@ -5,8 +6,10 @@ validator.ts(22,1): error TS2322: Type 'string' is not assignable to type 'numbe
validator.ts(23,1): error TS2322: Type 'number' is not assignable to type 'string'.
==== validator.ts (5 errors) ====
==== validator.ts (6 errors) ====
import "./";
~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './'.
import Person = require("./mod1");
@@ -3,6 +3,7 @@ main.ts(3,16): error TS2307: Cannot find module '../foo.mts' or its correspondin
main.ts(4,16): error TS2307: Cannot find module '../../foo.cts' or its corresponding type declarations.
main.ts(5,16): error TS2307: Cannot find module './foo.tsx' or its corresponding type declarations.
main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
main.ts(7,8): error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
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
==== globals.d.ts (0 errors) ====
declare function require(module: string): any;
==== main.ts (10 errors) ====
==== main.ts (11 errors) ====
// Rewrite
import {} from "./foo.ts";
~~~~~~~~~~
@@ -41,6 +42,8 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
~~~~~~~~~~
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
import "./foo.ts";
~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
export * from "./foo.ts";
~~~~~~~~~~
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
@@ -3,6 +3,7 @@ main.ts(3,16): error TS2307: Cannot find module '../foo.mts' or its correspondin
main.ts(4,16): error TS2307: Cannot find module '../../foo.cts' or its corresponding type declarations.
main.ts(5,16): error TS2307: Cannot find module './foo.tsx' or its corresponding type declarations.
main.ts(6,22): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
main.ts(7,8): error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
main.ts(8,15): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
main.ts(10,8): error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
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
==== globals.d.ts (0 errors) ====
declare function require(module: string): any;
==== main.ts (10 errors) ====
==== main.ts (11 errors) ====
// Rewrite
import {} from "./foo.ts";
~~~~~~~~~~
@@ -41,6 +42,8 @@ no.ts(11,8): error TS2307: Cannot find module 'node:path' or its corresponding t
~~~~~~~~~~
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
import "./foo.ts";
~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './foo.ts'.
export * from "./foo.ts";
~~~~~~~~~~
!!! error TS2307: Cannot find module './foo.ts' or its corresponding type declarations.
@@ -0,0 +1,10 @@
es6ImportWithoutFromClauseInEs5_1.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'es6ImportWithoutFromClauseInEs5_0'.
==== es6ImportWithoutFromClauseInEs5_0.ts (0 errors) ====
export var a = 10;
==== es6ImportWithoutFromClauseInEs5_1.ts (1 errors) ====
import "es6ImportWithoutFromClauseInEs5_0";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'es6ImportWithoutFromClauseInEs5_0'.
@@ -1,10 +1,13 @@
client.ts(1,1): error TS1191: An import declaration cannot have modifiers.
client.ts(1,15): error TS2882: Cannot find module or type declarations for side-effect import of 'server'.
==== server.ts (0 errors) ====
export var a = 10;
==== client.ts (1 errors) ====
==== client.ts (2 errors) ====
export import "server";
~~~~~~
!!! error TS1191: An import declaration cannot have modifiers.
!!! error TS1191: An import declaration cannot have modifiers.
~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'server'.
@@ -0,0 +1,20 @@
index.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './extention'.
==== extension.d.ts (0 errors) ====
declare global {
namespace globalThis {
var test: string;
}
}
export {}
==== index.ts (1 errors) ====
import "./extention";
~~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './extention'.
globalThis.tests = "a-b";
console.log(globalThis.test.split("-"));
@@ -24,6 +24,7 @@ globalThis.tests = "a-b";
>globalThis.tests = "a-b" : "a-b"
> : ^^^^^
>globalThis.tests : any
> : ^^^
>globalThis : typeof globalThis
> : ^^^^^^^^^^^^^^^^^
>tests : any
@@ -0,0 +1,16 @@
index.tsx(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './jsx'.
==== index.tsx (1 errors) ====
import "./jsx";
~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './jsx'.
var skate: any;
const React = { createElement: skate.h };
class Component {
renderCallback() {
return <div>test</div>;
}
};
@@ -5,6 +5,7 @@ import "./jsx";
var skate: any;
>skate : any
> : ^^^
const React = { createElement: skate.h };
>React : { createElement: any; }
@@ -12,7 +13,9 @@ const React = { createElement: skate.h };
>{ createElement: skate.h } : { createElement: any; }
> : ^^^^^^^^^^^^^^^^^^^^^^^
>createElement : any
> : ^^^
>skate.h : any
> : ^^^
>skate : any
> : ^^^
>h : any
@@ -27,7 +30,8 @@ class Component {
> : ^^^^^^^^^
return <div>test</div>;
><div>test</div> : error
><div>test</div> : any
> : ^^^
>div : any
> : ^^^
>div : any
@@ -0,0 +1,13 @@
jsxImportForSideEffectsNonExtantNoError.tsx(4,8): error TS2882: Cannot find module or type declarations for side-effect import of './App.css'.
==== jsxImportForSideEffectsNonExtantNoError.tsx (1 errors) ====
/// <reference path="/.lib/react16.d.ts" />
import * as React from "react";
import "./App.css"; // doesn't actually exist
~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of './App.css'.
const tag = <div></div>;
@@ -33,3 +33,30 @@ var y = x.getA().x;
//// [f.d.ts]
import "array";
//// [DtsFileErrors]
f.d.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'array'.
==== f.d.ts (1 errors) ====
import "array";
~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'array'.
==== array.d.ts (0 errors) ====
declare module "A" {
class A { x: number; }
}
declare module "array" {
import {A} from "A";
global {
interface Array<T> {
getA(): A;
}
}
}
@@ -106,3 +106,53 @@ declare module "main" {
import "D";
import "e";
}
//// [DtsFileErrors]
f.d.ts(20,12): error TS2882: Cannot find module or type declarations for side-effect import of 'D'.
==== f.d.ts (1 errors) ====
/// <reference path="c.d.ts" preserve="true" />
declare module "a" {
export class A {
}
}
declare module "b" {
export class B {
x: number;
}
}
declare module "e" {
import { Cls } from "C";
module "a" {
interface A {
getCls(): Cls;
}
}
}
declare module "main" {
import "D";
~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'D'.
import "e";
}
==== c.d.ts (0 errors) ====
declare module "C" {
class Cls {y: string; }
}
==== d.d.ts (0 errors) ====
declare module "D" {
import {A} from "a";
import {B} from "b";
module "a" {
interface A {
getB(): B;
}
}
}
@@ -93,3 +93,60 @@ declare module "main" {
import "D";
import "E";
}
//// [DtsFileErrors]
f.d.ts(11,12): error TS2882: Cannot find module or type declarations for side-effect import of 'D'.
f.d.ts(12,12): error TS2882: Cannot find module or type declarations for side-effect import of 'E'.
==== f.d.ts (2 errors) ====
declare module "a" {
export class A {
}
}
declare module "b" {
export class B {
x: number;
}
}
declare module "main" {
import "D";
~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'D'.
import "E";
~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'E'.
}
==== c.d.ts (0 errors) ====
declare module "C" {
class Cls {y: string; }
}
==== d.d.ts (0 errors) ====
declare module "D" {
import {A} from "a";
import {B} from "b";
module "a" {
interface A {
getB(): B;
}
}
}
==== e.d.ts (0 errors) ====
/// <reference path="c.d.ts"/>
declare module "E" {
import {A} from "a";
import {Cls} from "C";
module "a" {
interface A {
getCls(): Cls;
}
}
}
@@ -0,0 +1,14 @@
/a.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
==== /a.ts (1 errors) ====
import "foo";
~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
==== /node_modules/foo/foo.js (0 errors) ====
This file is not read.
==== /node_modules/foo/package.json (0 errors) ====
{ "types": "foo.js" }
@@ -1,3 +1,4 @@
file.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
@@ -22,9 +23,11 @@ subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
~~~~~~~~~~~
!!! error TS8003: 'export =' can only be used in TypeScript files.
==== file.js (1 errors) ====
==== file.js (2 errors) ====
// esm format file
import "fs";
~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
const a = {};
module.exports = a;
~~~~~~
@@ -1,3 +1,4 @@
file.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
@@ -22,9 +23,11 @@ subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
~~~~~~~~~~~
!!! error TS8003: 'export =' can only be used in TypeScript files.
==== file.js (1 errors) ====
==== file.js (2 errors) ====
// esm format file
import "fs";
~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
const a = {};
module.exports = a;
~~~~~~
@@ -1,3 +1,4 @@
file.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
@@ -22,9 +23,11 @@ subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
~~~~~~~~~~~
!!! error TS8003: 'export =' can only be used in TypeScript files.
==== file.js (1 errors) ====
==== file.js (2 errors) ====
// esm format file
import "fs";
~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
const a = {};
module.exports = a;
~~~~~~
@@ -1,3 +1,4 @@
file.js(2,8): error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files.
@@ -22,9 +23,11 @@ subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
~~~~~~~~~~~
!!! error TS8003: 'export =' can only be used in TypeScript files.
==== file.js (1 errors) ====
==== file.js (2 errors) ====
// esm format file
import "fs";
~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'fs'.
const a = {};
module.exports = a;
~~~~~~
@@ -1,3 +1,4 @@
/3.cjs(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
/3.cjs(2,1): error TS2304: Cannot find name 'exports'.
/5.cjs(2,8): error TS1192: Module '"/3"' has no default export.
@@ -8,8 +9,10 @@
==== /2.cjs (0 errors) ====
exports.foo = 0;
==== /3.cjs (1 errors) ====
==== /3.cjs (2 errors) ====
import "foo";
~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
exports.foo = {};
~~~~~~~
!!! error TS2304: Cannot find name 'exports'.
@@ -1,3 +1,4 @@
/3.cjs(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
/3.cjs(2,1): error TS2304: Cannot find name 'exports'.
/5.cjs(2,8): error TS1192: Module '"/3"' has no default export.
@@ -8,8 +9,10 @@
==== /2.cjs (0 errors) ====
exports.foo = 0;
==== /3.cjs (1 errors) ====
==== /3.cjs (2 errors) ====
import "foo";
~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
exports.foo = {};
~~~~~~~
!!! error TS2304: Cannot find name 'exports'.
@@ -1,3 +1,4 @@
/3.cjs(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
/3.cjs(2,1): error TS2304: Cannot find name 'exports'.
/5.cjs(2,8): error TS1192: Module '"/3"' has no default export.
@@ -8,8 +9,10 @@
==== /2.cjs (0 errors) ====
exports.foo = 0;
==== /3.cjs (1 errors) ====
==== /3.cjs (2 errors) ====
import "foo";
~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'foo'.
exports.foo = {};
~~~~~~~
!!! error TS2304: Cannot find name 'exports'.
@@ -1,4 +1,4 @@
/index.ts(2,8): error TS2307: Cannot find module 'i-have-a-dir-and-main/dist/dir' or its corresponding type declarations.
/index.ts(2,8): error TS2882: Cannot find module or type declarations for side-effect import of 'i-have-a-dir-and-main/dist/dir'.
==== /node_modules/i-have-a-dir-and-main/package.json (0 errors) ====
@@ -22,5 +22,5 @@
import 'i-have-a-dir-and-main' // ok
import 'i-have-a-dir-and-main/dist/dir' // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'i-have-a-dir-and-main/dist/dir' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'i-have-a-dir-and-main/dist/dir'.
@@ -1,6 +1,7 @@
tsconfig.json(6,11): error TS5061: Pattern '@interface/**/*' can have at most one '*' character.
tsconfig.json(7,11): error TS5061: Pattern '@service/**/*' can have at most one '*' character.
tsconfig.json(7,29): error TS5062: Substitution './src/service/**/*' in pattern '@service/**/*' can have at most one '*' character.
src/main.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'someModule'.
==== tsconfig.json (3 errors) ====
@@ -22,5 +23,7 @@ tsconfig.json(7,29): error TS5062: Substitution './src/service/**/*' in pattern
}
}
==== src/main.ts (0 errors) ====
import 'someModule';
==== src/main.ts (1 errors) ====
import 'someModule';
~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'someModule'.
@@ -1,6 +1,7 @@
tsconfig.json(5,26): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
tsconfig.json(6,19): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
tsconfig.json(7,23): error TS5090: Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?
src/main.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'someModule'.
==== tsconfig.json (3 errors) ====
@@ -21,5 +22,7 @@ tsconfig.json(7,23): error TS5090: Non-relative paths are not allowed when 'base
}
}
==== src/main.ts (0 errors) ====
import 'someModule';
==== src/main.ts (1 errors) ====
import 'someModule';
~~~~~~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'someModule'.
@@ -1,16 +1,16 @@
sideEffectImports1.ts(1,8): error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
sideEffectImports1.ts(2,8): error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
sideEffectImports1.ts(3,8): error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
sideEffectImports1.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
sideEffectImports1.ts(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
sideEffectImports1.ts(3,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
==== sideEffectImports1.ts (3 errors) ====
import "does-not-exist";
~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
import "./does-not-exist-either";
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
import "./does-not-exist-either.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
@@ -1,16 +1,16 @@
sideEffectImports1.ts(1,8): error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
sideEffectImports1.ts(2,8): error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
sideEffectImports1.ts(3,8): error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
sideEffectImports1.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
sideEffectImports1.ts(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
sideEffectImports1.ts(3,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
==== sideEffectImports1.ts (3 errors) ====
import "does-not-exist";
~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
import "./does-not-exist-either";
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
import "./does-not-exist-either.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
@@ -1,16 +1,16 @@
sideEffectImports1.ts(1,8): error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
sideEffectImports1.ts(2,8): error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
sideEffectImports1.ts(3,8): error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
sideEffectImports1.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
sideEffectImports1.ts(2,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
sideEffectImports1.ts(3,8): error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
==== sideEffectImports1.ts (3 errors) ====
import "does-not-exist";
~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
import "./does-not-exist-either";
~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either'.
import "./does-not-exist-either.js";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations.
!!! error TS2882: Cannot find module or type declarations for side-effect import of './does-not-exist-either.js'.
@@ -1,12 +1,13 @@
systemModule9.ts(1,21): error TS2792: Cannot find module 'file1'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
systemModule9.ts(2,25): error TS2792: Cannot find module 'file2'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
systemModule9.ts(3,15): error TS2792: Cannot find module 'file3'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
systemModule9.ts(4,8): error TS2882: Cannot find module or type declarations for side-effect import of 'file4'.
systemModule9.ts(5,25): error TS2792: Cannot find module 'file5'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
systemModule9.ts(6,22): error TS2792: Cannot find module 'file6'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
systemModule9.ts(16,15): error TS2792: Cannot find module 'file7'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
==== systemModule9.ts (6 errors) ====
==== systemModule9.ts (7 errors) ====
import * as ns from 'file1';
~~~~~~~
!!! error TS2792: Cannot find module 'file1'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
@@ -17,6 +18,8 @@ systemModule9.ts(16,15): error TS2792: Cannot find module 'file7'. Did you mean
~~~~~~~
!!! error TS2792: Cannot find module 'file3'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
import 'file4'
~~~~~~~
!!! error TS2882: Cannot find module or type declarations for side-effect import of 'file4'.
import e, * as ns2 from 'file5';
~~~~~~~
!!! error TS2792: Cannot find module 'file5'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?
@@ -101,7 +101,7 @@ default: false
--noUncheckedSideEffectImports
Check side effect imports.
type: boolean
default: false
default: true
--paths
Specify a set of entries that re-map imports to additional lookup locations.
@@ -47,7 +47,12 @@ DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_mod
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Type roots
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules/@types 1 undefined Type roots
[HH:MM:SS AM] Found 0 errors. Watching for file changes.
b.ts:1:8 - error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled.
1 import "./a.ts";
   ~~~~~~~~
[HH:MM:SS AM] Found 1 error. Watching for file changes.
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
@@ -149,7 +149,7 @@ Synchronizing program
CreatingProgramWith::
roots: ["/user/username/projects/myproject/a.ts"]
options: {"noUncheckedSideEffectImports":true,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
a.ts:1:8 - error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations.
a.ts:1:8 - error TS2882: Cannot find module or type declarations for side-effect import of 'does-not-exist'.
1 import "does-not-exist";
   ~~~~~~~~~~~~~~~~
@@ -1,4 +1,6 @@
// @filename: foo.d.ts
// @noUncheckedSideEffectImports: false
export default 2 + 2;
export as namespace Foo;
@@ -1,5 +1,6 @@
// @module: commonjs
// @declaration: true
// @noUncheckedSideEffectImports: false
// @filename: f1.d.ts
declare module "A" {
global {
@@ -1,5 +1,6 @@
// @noImplicitReferences: true
// @traceResolution: true
// @noUncheckedSideEffectImports: false
// This tests that a package.json "main" with an unexpected extension is ignored.
// @Filename: /node_modules/normalize.css/normalize.css