diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8372bdcb7c3..e589fbbbf98 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -720,6 +720,7 @@ import { isSetAccessorDeclaration, isShorthandAmbientModuleSymbol, isShorthandPropertyAssignment, + isSideEffectImport, isSingleOrDoubleQuote, isSourceFile, isSourceFileJS, @@ -1505,6 +1506,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 checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); @@ -4660,7 +4662,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); } - if (errorNode && moduleNotFoundError) { + if (errorNode && moduleNotFoundError && !isSideEffectImport(errorNode)) { // report errors only if it was requested error(errorNode, Diagnostics.File_0_is_not_a_module, sourceFile.fileName); } @@ -4765,6 +4767,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function errorOnImplicitAnyModule(isError: boolean, errorNode: Node, sourceFile: SourceFile, mode: ResolutionMode, { packageId, resolvedFileName }: ResolvedModuleFull, moduleReference: string): void { + if (isSideEffectImport(errorNode)) { + return; + } + let errorInfo: DiagnosticMessageChain | undefined; if (!isExternalModuleNameRelative(moduleReference) && packageId) { errorInfo = createModuleNotFoundChain(sourceFile, host, moduleReference, mode, packageId.name); @@ -47246,6 +47252,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } } + else if (noUncheckedSideEffectImports && !importClause) { + void resolveExternalModuleName(node, node.moduleSpecifier); + } } checkImportAttributes(node); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f0ccc291ffb..13764554943 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1202,6 +1202,15 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ category: Diagnostics.Modules, description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports, }, + { + name: "noUncheckedSideEffectImports", + type: "boolean", + affectsSemanticDiagnostics: true, + affectsBuildInfo: true, + category: Diagnostics.Modules, + description: Diagnostics.Check_side_effect_imports, + defaultValueDescription: false, + }, // Source Maps { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8c40f2f860e..8b9024132ab 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -6388,6 +6388,10 @@ "category": "Message", "code": 6805 }, + "Check side effect imports.": { + "category": "Message", + "code": 6806 + }, "one of:": { "category": "Message", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28d69a39e4d..7ccdae935b1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7418,6 +7418,7 @@ export interface CompilerOptions { target?: ScriptTarget; traceResolution?: boolean; useUnknownInCatchVariables?: boolean; + noUncheckedSideEffectImports?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b29944a5236..458c589b63e 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -287,6 +287,7 @@ import { isIdentifier, isIdentifierStart, isIdentifierText, + isImportDeclaration, isImportTypeNode, isInterfaceDeclaration, isJSDoc, @@ -11758,3 +11759,9 @@ export function hasInferredType(node: Node): node is HasInferredType { return false; } } + +/** @internal */ +export function isSideEffectImport(node: Node): boolean { + const ancestor = findAncestor(node, isImportDeclaration); + return !!ancestor && !ancestor.importClause; +} diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index 626367c7f30..6bfa06fcaa4 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -2245,4 +2245,40 @@ import { x } from "../b";`, }, ], }); + + verifyTscWatch({ + scenario, + subScenario: "when changing noUncheckedSideEffectImports of config file", + commandLineArgs: ["-w", "-p", ".", "--extendedDiagnostics"], + sys: () => { + const module1: File = { + path: `/user/username/projects/myproject/a.ts`, + content: `import "does-not-exist";`, + }; + const config: File = { + path: `/user/username/projects/myproject/tsconfig.json`, + content: jsonToReadableText({ + compilerOptions: { + noUncheckedSideEffectImports: false, + }, + }), + }; + return createWatchedSystem([module1, config, libFile], { currentDirectory: "/user/username/projects/myproject" }); + }, + edits: [ + { + caption: "Change noUncheckedSideEffectImports to true", + edit: sys => + sys.writeFile( + `/user/username/projects/myproject/tsconfig.json`, + jsonToReadableText({ + compilerOptions: { + noUncheckedSideEffectImports: true, + }, + }), + ), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ], + }); }); diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3855078b1f2..85d35b85c9c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -7017,6 +7017,7 @@ declare namespace ts { target?: ScriptTarget; traceResolution?: boolean; useUnknownInCatchVariables?: boolean; + noUncheckedSideEffectImports?: boolean; resolveJsonModule?: boolean; types?: string[]; /** Paths used to compute primary types search locations */ diff --git a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json index a7774be58c9..56a8ab81090 100644 --- a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json index a7774be58c9..56a8ab81090 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json index a7774be58c9..56a8ab81090 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json index 705b9f76e01..2128e19b491 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index ebe2ee57e90..3a57b6b66b6 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 46fb71d52c3..457ad18d7fd 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json index 300866f96a8..3c272c2c102 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 8a8db313c21..cbec354c31b 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index a7774be58c9..56a8ab81090 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 84f23824275..49877df48bb 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json index 6494b47ae9e..79727a965d6 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -39,6 +39,7 @@ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/noUncheckedSideEffectImports/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/noUncheckedSideEffectImports/tsconfig.json new file mode 100644 index 00000000000..ebfea7ecd97 --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/noUncheckedSideEffectImports/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "noUncheckedSideEffectImports": true + } +} diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..b9f2790a4b2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("does-not-exist"); +require("./does-not-exist-either"); +require("./does-not-exist-either.js"); diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=false).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).errors.txt b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).errors.txt new file mode 100644 index 00000000000..e1813116cb0 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).errors.txt @@ -0,0 +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 (3 errors) ==== + import "does-not-exist"; + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations. + import "./does-not-exist-either"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations. + import "./does-not-exist-either.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..b9f2790a4b2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("does-not-exist"); +require("./does-not-exist-either"); +require("./does-not-exist-either.js"); diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=commonjs,nouncheckedsideeffectimports=true).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..b9f2790a4b2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("does-not-exist"); +require("./does-not-exist-either"); +require("./does-not-exist-either.js"); diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=false).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).errors.txt b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).errors.txt new file mode 100644 index 00000000000..e1813116cb0 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).errors.txt @@ -0,0 +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 (3 errors) ==== + import "does-not-exist"; + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations. + import "./does-not-exist-either"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations. + import "./does-not-exist-either.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..b9f2790a4b2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("does-not-exist"); +require("./does-not-exist-either"); +require("./does-not-exist-either.js"); diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=nodenext,nouncheckedsideeffectimports=true).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..6885c11fb0d --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=false).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).errors.txt b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).errors.txt new file mode 100644 index 00000000000..e1813116cb0 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).errors.txt @@ -0,0 +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 (3 errors) ==== + import "does-not-exist"; + ~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'does-not-exist' or its corresponding type declarations. + import "./does-not-exist-either"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either' or its corresponding type declarations. + import "./does-not-exist-either.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './does-not-exist-either.js' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..6885c11fb0d --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +//// [sideEffectImports1.ts] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + + +//// [sideEffectImports1.js] +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..e9f4818d85a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports1(module=preserve,nouncheckedsideeffectimports=true).types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/sideEffectImports1.ts] //// + +=== sideEffectImports1.ts === + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=false).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=false,nouncheckedsideeffectimports=true).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=false).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..aa7b41f4c55 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports2(noimplicitany=true,nouncheckedsideeffectimports=true).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports2.ts] //// + +=== index.ts === + +import "source-map-support/register"; + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..f0426f699a2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=false).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..f0426f699a2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=auto,nouncheckedsideeffectimports=true).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..47f2c895605 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=false).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..47f2c895605 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=force,nouncheckedsideeffectimports=true).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..f0426f699a2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=false).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..f0426f699a2 --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +//// [index.ts] +import "./not-a-module"; + +//// [not-a-module.ts] +console.log("Hello, world!"); + + +//// [not-a-module.js] +console.log("Hello, world!"); +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("./not-a-module"); diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..727efa084be --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) +>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) +>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) + diff --git a/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..a956316561e --- /dev/null +++ b/tests/baselines/reference/sideEffectImports3(moduledetection=legacy,nouncheckedsideeffectimports=true).types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/sideEffectImports3.ts] //// + +=== index.ts === + +import "./not-a-module"; + +=== not-a-module.ts === +console.log("Hello, world!"); +>console.log("Hello, world!") : void +> : ^^^^ +>console.log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>console : Console +> : ^^^^^^^ +>log : (...data: any[]) => void +> : ^^^^ ^^ ^^^^^ +>"Hello, world!" : "Hello, world!" +> : ^^^^^^^^^^^^^^^ + diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).js b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).js new file mode 100644 index 00000000000..4dd388e90fe --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +//// [package.json] +{ + "name": "server-only", + "version": "0.0.1", + "main": "index.js", + "exports": { + ".": { + "react-server": "./empty.js", + "default": "./index.js" + } + } +} + +//// [index.js] +throw new Error(); + +//// [empty.js] +// Empty + +//// [package.json] +{ + "name": "root", + "type": "module" +} + +//// [index.ts] +import "server-only"; + + +//// [index.js] +import "server-only"; diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).symbols b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).symbols new file mode 100644 index 00000000000..6e5527be87a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +=== index.ts === + +import "server-only"; + diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).types b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).types new file mode 100644 index 00000000000..6e5527be87a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=false).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +=== index.ts === + +import "server-only"; + diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).js b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).js new file mode 100644 index 00000000000..4dd388e90fe --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +//// [package.json] +{ + "name": "server-only", + "version": "0.0.1", + "main": "index.js", + "exports": { + ".": { + "react-server": "./empty.js", + "default": "./index.js" + } + } +} + +//// [index.js] +throw new Error(); + +//// [empty.js] +// Empty + +//// [package.json] +{ + "name": "root", + "type": "module" +} + +//// [index.ts] +import "server-only"; + + +//// [index.js] +import "server-only"; diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).symbols b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).symbols new file mode 100644 index 00000000000..6e5527be87a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +=== index.ts === + +import "server-only"; + diff --git a/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).types b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).types new file mode 100644 index 00000000000..6e5527be87a --- /dev/null +++ b/tests/baselines/reference/sideEffectImports4(nouncheckedsideeffectimports=true).types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/sideEffectImports4.ts] //// + +=== index.ts === + +import "server-only"; + diff --git a/tests/baselines/reference/tscWatch/programUpdates/when-changing-noUncheckedSideEffectImports-of-config-file.js b/tests/baselines/reference/tscWatch/programUpdates/when-changing-noUncheckedSideEffectImports-of-config-file.js new file mode 100644 index 00000000000..2a15f0cc1f6 --- /dev/null +++ b/tests/baselines/reference/tscWatch/programUpdates/when-changing-noUncheckedSideEffectImports-of-config-file.js @@ -0,0 +1,172 @@ +currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames: false +Input:: +//// [/user/username/projects/myproject/a.ts] +import "does-not-exist"; + +//// [/user/username/projects/myproject/tsconfig.json] +{ + "compilerOptions": { + "noUncheckedSideEffectImports": false + } +} + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -w -p . --extendedDiagnostics +Output:: +[HH:MM:SS AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file +Synchronizing program +CreatingProgramWith:: + roots: ["/user/username/projects/myproject/a.ts"] + options: {"noUncheckedSideEffectImports":false,"watch":true,"project":"/user/username/projects/myproject","extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/a.ts 250 undefined Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules 1 undefined Failed Lookup Locations +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/node_modules 1 undefined Failed Lookup Locations +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots +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. + +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 + + +//// [/user/username/projects/myproject/a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("does-not-exist"); + + + +PolledWatches:: +/user/username/projects/myproject/node_modules: *new* + {"pollingInterval":500} +/user/username/projects/myproject/node_modules/@types: *new* + {"pollingInterval":500} +/user/username/projects/node_modules: *new* + {"pollingInterval":500} +/user/username/projects/node_modules/@types: *new* + {"pollingInterval":500} + +FsWatches:: +/a/lib/lib.d.ts: *new* + {} +/user/username/projects/myproject/a.ts: *new* + {} +/user/username/projects/myproject/tsconfig.json: *new* + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: *new* + {} + +Program root files: [ + "/user/username/projects/myproject/a.ts" +] +Program options: { + "noUncheckedSideEffectImports": false, + "watch": true, + "project": "/user/username/projects/myproject", + "extendedDiagnostics": true, + "configFilePath": "/user/username/projects/myproject/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/myproject/a.ts (used version) + +exitCode:: ExitStatus.undefined + +Change:: Change noUncheckedSideEffectImports to true + +Input:: +//// [/user/username/projects/myproject/tsconfig.json] +{ + "compilerOptions": { + "noUncheckedSideEffectImports": true + } +} + + +Output:: +FileWatcher:: Triggered with /user/username/projects/myproject/tsconfig.json 1:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/tsconfig.json 1:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file + + +Timeout callback:: count: 1 +1: timerToUpdateProgram *new* + +Before running Timeout callback:: count: 1 +1: timerToUpdateProgram + +Host is moving to new time +After running Timeout callback:: count: 0 +Output:: +Reloading config file: /user/username/projects/myproject/tsconfig.json +Synchronizing program +[HH:MM:SS AM] File change detected. Starting incremental compilation... + +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. + +1 import "does-not-exist"; +   ~~~~~~~~~~~~~~~~ + +[HH:MM:SS AM] Found 1 error. Watching for file changes. + + + + + +Program root files: [ + "/user/username/projects/myproject/a.ts" +] +Program options: { + "noUncheckedSideEffectImports": true, + "watch": true, + "project": "/user/username/projects/myproject", + "extendedDiagnostics": true, + "configFilePath": "/user/username/projects/myproject/tsconfig.json" +} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined diff --git a/tests/cases/compiler/sideEffectImports1.ts b/tests/cases/compiler/sideEffectImports1.ts new file mode 100644 index 00000000000..d65ddd2ed57 --- /dev/null +++ b/tests/cases/compiler/sideEffectImports1.ts @@ -0,0 +1,6 @@ +// @noUncheckedSideEffectImports: true,false +// @module: commonjs,nodenext,preserve + +import "does-not-exist"; +import "./does-not-exist-either"; +import "./does-not-exist-either.js"; diff --git a/tests/cases/compiler/sideEffectImports2.ts b/tests/cases/compiler/sideEffectImports2.ts new file mode 100644 index 00000000000..69050023319 --- /dev/null +++ b/tests/cases/compiler/sideEffectImports2.ts @@ -0,0 +1,17 @@ +// @noUncheckedSideEffectImports: true,false +// @module: nodenext +// @noImplicitAny: true,false +// @noEmit: true + +// @filename: tsconfig.json +{ + "include": ["index.ts"], +} + +// @filename: index.ts + +import "source-map-support/register"; + +// @filename: node_modules/source-map-support/register.js + +module.exports = {}; diff --git a/tests/cases/compiler/sideEffectImports3.ts b/tests/cases/compiler/sideEffectImports3.ts new file mode 100644 index 00000000000..dba921939c7 --- /dev/null +++ b/tests/cases/compiler/sideEffectImports3.ts @@ -0,0 +1,9 @@ +// @noUncheckedSideEffectImports: true,false +// @module: nodenext +// @moduleDetection: legacy,auto,force + +// @filename: index.ts +import "./not-a-module"; + +// @filename: not-a-module.ts +console.log("Hello, world!"); diff --git a/tests/cases/compiler/sideEffectImports4.ts b/tests/cases/compiler/sideEffectImports4.ts new file mode 100644 index 00000000000..8ae1cc3ac87 --- /dev/null +++ b/tests/cases/compiler/sideEffectImports4.ts @@ -0,0 +1,36 @@ +// @noUncheckedSideEffectImports: true,false +// @strict: true +// @noImplicitReferences: true +// @module: esnext +// @moduleResolution: bundler +// @moduleDetection: force +// @allowJs: true +// @checkJs: true + +// @filename: node_modules/server-only/package.json +{ + "name": "server-only", + "version": "0.0.1", + "main": "index.js", + "exports": { + ".": { + "react-server": "./empty.js", + "default": "./index.js" + } + } +} + +// @filename: node_modules/server-only/index.js +throw new Error(); + +// @filename: node_modules/server-only/empty.js +// Empty + +// @filename: package.json +{ + "name": "root", + "type": "module" +} + +// @filename: index.ts +import "server-only"; diff --git a/tests/cases/fourslash/sideEffectImportsSuggestion1.ts b/tests/cases/fourslash/sideEffectImportsSuggestion1.ts new file mode 100644 index 00000000000..80cd37f3ae3 --- /dev/null +++ b/tests/cases/fourslash/sideEffectImportsSuggestion1.ts @@ -0,0 +1,19 @@ +/// + +// @allowJs: true +// @noEmit: true +// @module: commonjs +// @noUncheckedSideEffectImports: true + +// @filename: moduleA/a.js +//// import "b"; +//// import "c"; + +// @filename: node_modules/b.ts +//// var a = 10; + +// @filename: node_modules/c.js +//// exports.a = 10; +//// c = 10; + +verify.getSuggestionDiagnostics([]);