From f961c3445ae77894df2b291eed94d7c474807f62 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 28 Jul 2022 16:59:50 -0700 Subject: [PATCH 1/6] Update error messages for CJS imports resolving to ES modules --- src/compiler/checker.ts | 27 +++- src/compiler/diagnosticMessages.json | 14 +- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/program.ts | 1 + src/compiler/types.ts | 1 + src/server/editorServices.ts | 4 +- src/server/packageJsonCache.ts | 8 +- src/server/project.ts | 4 +- src/services/types.ts | 6 +- src/services/utilities.ts | 8 +- ...sPackageSelfName(module=node16).errors.txt | 4 +- ...ackageSelfName(module=nodenext).errors.txt | 4 +- .../nodeModules1(module=node16).errors.txt | 104 +++++++------- .../nodeModules1(module=nodenext).errors.txt | 104 +++++++------- ...eModulesAllowJs1(module=node16).errors.txt | 104 +++++++------- ...odulesAllowJs1(module=nodenext).errors.txt | 104 +++++++------- ...alPackageExports(module=node16).errors.txt | 8 +- ...PackageExports(module=nodenext).errors.txt | 8 +- ...JsPackageExports(module=node16).errors.txt | 20 +-- ...PackageExports(module=nodenext).errors.txt | 20 +-- ...JsPackageImports(module=node16).errors.txt | 8 +- ...PackageImports(module=nodenext).errors.txt | 8 +- ...gePatternExports(module=node16).errors.txt | 12 +- ...PatternExports(module=nodenext).errors.txt | 12 +- ...nExportsTrailers(module=node16).errors.txt | 12 +- ...xportsTrailers(module=nodenext).errors.txt | 12 +- ...ronousCallErrors(module=node16).errors.txt | 13 +- ...nousCallErrors(module=nodenext).errors.txt | 13 +- ...esolvingToESM1_emptyPackageJson.errors.txt | 28 ++++ ...SResolvingToESM2_cjsPackageJson.errors.txt | 27 ++++ ...solvingToESM3_modulePackageJson.errors.txt | 19 +++ ...JSResolvingToESM4_noPackageJson.errors.txt | 24 ++++ ...alPackageExports(module=node16).errors.txt | 8 +- ...PackageExports(module=nodenext).errors.txt | 8 +- ...thPackageExports(module=node16).errors.txt | 20 +-- ...PackageExports(module=nodenext).errors.txt | 20 +-- ...esPackageExports(module=node16).errors.txt | 20 +-- ...PackageExports(module=nodenext).errors.txt | 20 +-- ...esPackageImports(module=node16).errors.txt | 8 +- ...PackageImports(module=nodenext).errors.txt | 8 +- ...gePatternExports(module=node16).errors.txt | 12 +- ...PatternExports(module=nodenext).errors.txt | 12 +- ...rnExportsExclude(module=node16).errors.txt | 12 +- ...ExportsExclude(module=nodenext).errors.txt | 12 +- ...nExportsTrailers(module=node16).errors.txt | 12 +- ...xportsTrailers(module=nodenext).errors.txt | 12 +- ...ronousCallErrors(module=node16).errors.txt | 13 +- ...nousCallErrors(module=nodenext).errors.txt | 13 +- ...ePackageSelfName(module=node16).errors.txt | 4 +- ...ackageSelfName(module=nodenext).errors.txt | 4 +- ...geSelfNameScoped(module=node16).errors.txt | 4 +- ...SelfNameScoped(module=nodenext).errors.txt | 4 +- ...t-correctly-with-cts-and-mts-extensions.js | 130 +++++++++++++++++- ...ulesCJSResolvingToESM1_emptyPackageJson.ts | 20 +++ ...odulesCJSResolvingToESM2_cjsPackageJson.ts | 20 +++ ...lesCJSResolvingToESM3_modulePackageJson.ts | 20 +++ ...ModulesCJSResolvingToESM4_noPackageJson.ts | 17 +++ 57 files changed, 758 insertions(+), 418 deletions(-) create mode 100644 tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt create mode 100644 tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt create mode 100644 tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt create mode 100644 tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt create mode 100644 tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts create mode 100644 tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts create mode 100644 tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts create mode 100644 tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8556832569b76..9f93b11710a53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3581,7 +3581,32 @@ namespace ts { // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ModuleKind.ESNext && !getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (findAncestor(location, isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + const diag = error(errorNode, Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference); + const ext = tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === Extension.Ts || ext === Extension.Js) { + const scope = host.getPackageScopeForPath(currentSourceFile.path); + const targetExt = ext === Extension.Ts ? Extension.Mts : Extension.Mjs; + if (scope && !scope.packageJsonContent.type) { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_type_Colon_module_to_its_package_json_file_with_path_1, + targetExt, + combinePaths(scope.packageDirectory, "package.json"))); + } + else { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0, + targetExt)); + } + } + } } } // merged symbol is module declaration symbol combined with all augmentations diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8ac65ebb8e1fa..d08a2d6e44a23 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1469,7 +1469,7 @@ "category": "Error", "code": 1470 }, - "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.": { + "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead.": { "category": "Error", "code": 1471 }, @@ -1501,6 +1501,18 @@ "category": "Error", "code": 1478 }, + "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead.": { + "category": "Error", + "code": 1479 + }, + "To convert this file to an ECMAScript module, change its file extension to '{0}'.": { + "category": "Message", + "code": 1480 + }, + "To convert this file to an ECMAScript module, change its file extension to '{0}', or add `\"type\": \"module\"` to its package.json file with path '{1}'.": { + "category": "Message", + "code": 1481 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 11cb17e60a978..4e4f8c91fc8bf 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1786,7 +1786,7 @@ namespace ts { } /*@internal*/ - interface PackageJsonInfo { + export interface PackageJsonInfo { packageDirectory: string; packageJsonContent: PackageJsonPathFields; versionPaths: VersionPaths | undefined; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c5803169c3409..85e032cccfa70 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1325,6 +1325,7 @@ namespace ts { directoryExists, getSymlinkCache, realpath: host.realpath?.bind(host), + getPackageScopeForPath: path => getPackageScopeForPath(path, getTemporaryModuleResolutionState(moduleResolutionCache?.getPackageJsonInfoCache(), host, options)), useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), getFileIncludeReasons: () => fileReasons, structureIsReused, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f93f36c369157..bf04ed84ce838 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4353,6 +4353,7 @@ namespace ts { getResolvedTypeReferenceDirectives(): ModeAwareCache; getProjectReferenceRedirect(fileName: string): string | undefined; isSourceOfProjectReferenceRedirect(fileName: string): boolean; + getPackageScopeForPath(path: Path): PackageJsonInfo | undefined; readonly redirectTargetsMap: RedirectTargetsMap; } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6cca27c033587..76c6678e0eb41 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -4185,11 +4185,11 @@ namespace ts.server { } /*@internal*/ - getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly PackageJsonInfo[] { + getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[] { const packageJsonCache = this.packageJsonCache; const rootPath = rootDir && this.toPath(rootDir); const filePath = this.toPath(fileName); - const result: PackageJsonInfo[] = []; + const result: ProjectPackageJsonInfo[] = []; const processDirectory = (directory: Path): boolean | undefined => { switch (packageJsonCache.directoryHasPackageJson(directory)) { // Sync and check same directory again diff --git a/src/server/packageJsonCache.ts b/src/server/packageJsonCache.ts index 3aa6129430a53..5c88fb9334dd5 100644 --- a/src/server/packageJsonCache.ts +++ b/src/server/packageJsonCache.ts @@ -2,16 +2,16 @@ namespace ts.server { export interface PackageJsonCache { addOrUpdate(fileName: Path): void; - forEach(action: (info: PackageJsonInfo, fileName: Path) => void): void; + forEach(action: (info: ProjectPackageJsonInfo, fileName: Path) => void): void; delete(fileName: Path): void; - get(fileName: Path): PackageJsonInfo | false | undefined; - getInDirectory(directory: Path): PackageJsonInfo | undefined; + get(fileName: Path): ProjectPackageJsonInfo | false | undefined; + getInDirectory(directory: Path): ProjectPackageJsonInfo | undefined; directoryHasPackageJson(directory: Path): Ternary; searchDirectoryAndAncestors(directory: Path): void; } export function createPackageJsonCache(host: ProjectService): PackageJsonCache { - const packageJsons = new Map(); + const packageJsons = new Map(); const directoriesWithoutPackageJson = new Map(); return { addOrUpdate, diff --git a/src/server/project.ts b/src/server/project.ts index 3ee83ea4c8cd0..c951325acfa05 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1751,7 +1751,7 @@ namespace ts.server { } /*@internal*/ - getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly PackageJsonInfo[] { + getPackageJsonsVisibleToFile(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[] { if (this.projectService.serverMode !== LanguageServiceMode.Semantic) return emptyArray; return this.projectService.getPackageJsonsVisibleToFile(fileName, rootDir); } @@ -1762,7 +1762,7 @@ namespace ts.server { } /*@internal*/ - getPackageJsonsForAutoImport(rootDir?: string): readonly PackageJsonInfo[] { + getPackageJsonsForAutoImport(rootDir?: string): readonly ProjectPackageJsonInfo[] { const packageJsons = this.getPackageJsonsVisibleToFile(combinePaths(this.currentDirectory, inferredTypesContainingFile), rootDir); this.packageJsonsForAutoImport = new Set(packageJsons.map(p => p.fileName)); return packageJsons; diff --git a/src/services/types.ts b/src/services/types.ts index b9015a736d430..15dd049554aa7 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -197,7 +197,7 @@ namespace ts { } /* @internal */ - export interface PackageJsonInfo { + export interface ProjectPackageJsonInfo { fileName: string; parseable: boolean; dependencies?: ESMap; @@ -311,9 +311,9 @@ namespace ts { /* @internal */ getDocumentPositionMapper?(generatedFileName: string, sourceFileName?: string): DocumentPositionMapper | undefined; /* @internal */ getSourceFileLike?(fileName: string): SourceFileLike | undefined; - /* @internal */ getPackageJsonsVisibleToFile?(fileName: string, rootDir?: string): readonly PackageJsonInfo[]; + /* @internal */ getPackageJsonsVisibleToFile?(fileName: string, rootDir?: string): readonly ProjectPackageJsonInfo[]; /* @internal */ getNearestAncestorDirectoryWithPackageJson?(fileName: string): string | undefined; - /* @internal */ getPackageJsonsForAutoImport?(rootDir?: string): readonly PackageJsonInfo[]; + /* @internal */ getPackageJsonsForAutoImport?(rootDir?: string): readonly ProjectPackageJsonInfo[]; /* @internal */ getCachedExportInfoMap?(): ExportInfoMap; /* @internal */ getModuleSpecifierCache?(): ModuleSpecifierCache; /* @internal */ setCompilerHost?(host: CompilerHost): void; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 4d42deb27cff8..a3676d4ae11d6 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -3004,12 +3004,12 @@ namespace ts { return packageJson; } - export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly PackageJsonInfo[] { + export function getPackageJsonsVisibleToFile(fileName: string, host: LanguageServiceHost): readonly ProjectPackageJsonInfo[] { if (!host.fileExists) { return []; } - const packageJsons: PackageJsonInfo[] = []; + const packageJsons: ProjectPackageJsonInfo[] = []; forEachAncestorDirectory(getDirectoryPath(fileName), ancestor => { const packageJsonFileName = combinePaths(ancestor, "package.json"); if (host.fileExists(packageJsonFileName)) { @@ -3023,7 +3023,7 @@ namespace ts { return packageJsons; } - export function createPackageJsonInfo(fileName: string, host: { readFile?(fileName: string): string | undefined }): PackageJsonInfo | undefined { + export function createPackageJsonInfo(fileName: string, host: { readFile?(fileName: string): string | undefined }): ProjectPackageJsonInfo | undefined { if (!host.readFile) { return undefined; } @@ -3032,7 +3032,7 @@ namespace ts { const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"] as const; const stringContent = host.readFile(fileName) || ""; const content = tryParseJson(stringContent) as PackageJsonRaw | undefined; - const info: Pick = {}; + const info: Pick = {}; if (content) { for (const key of dependencyKeys) { const dependencies = content[key]; diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt index 42a324dadf666..45e5c345de24c 100644 --- a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=node16).errors.txt @@ -1,5 +1,5 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -15,7 +15,7 @@ tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'pack // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. self; ==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt index 42a324dadf666..45e5c345de24c 100644 --- a/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeAllowJsPackageSelfName(module=nodenext).errors.txt @@ -1,5 +1,5 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -15,7 +15,7 @@ tests/cases/conformance/node/allowJs/index.cjs(2,23): error TS1471: Module 'pack // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. self; ==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodeModules1(module=node16).errors.txt b/tests/baselines/reference/nodeModules1(module=node16).errors.txt index e8bcd1c06a711..fdadf6a8f5c13 100644 --- a/tests/baselines/reference/nodeModules1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=node16).errors.txt @@ -1,19 +1,19 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. +tests/cases/conformance/node/index.cts(3,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. +tests/cases/conformance/node/index.cts(6,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(9,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(11,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. +tests/cases/conformance/node/index.cts(12,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(15,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. +tests/cases/conformance/node/index.cts(16,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. +tests/cases/conformance/node/index.cts(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. +tests/cases/conformance/node/index.cts(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. +tests/cases/conformance/node/index.cts(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. +tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.cts(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.cts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -36,11 +36,11 @@ tests/cases/conformance/node/index.mts(21,22): error TS2835: Relative import pat tests/cases/conformance/node/index.mts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.mts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.mts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.mts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.mts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -63,11 +63,11 @@ tests/cases/conformance/node/index.ts(21,22): error TS2835: Relative import path tests/cases/conformance/node/index.ts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.ts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.ts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.ts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.ts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -191,10 +191,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -203,13 +203,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -264,35 +264,35 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. import * as m12 from "./subfolder2/another/index.cjs"; // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) import * as m13 from "./"; ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. import * as m15 from "./subfolder"; import * as m16 from "./subfolder/"; import * as m17 from "./subfolder/index"; @@ -301,13 +301,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import * as m20 from "./subfolder2/index"; import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. void m1; void m2; void m3; @@ -335,10 +335,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -347,13 +347,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -477,10 +477,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -489,13 +489,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt index e8bcd1c06a711..fdadf6a8f5c13 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -1,19 +1,19 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. +tests/cases/conformance/node/index.cts(3,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. +tests/cases/conformance/node/index.cts(6,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(9,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(11,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. +tests/cases/conformance/node/index.cts(12,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. +tests/cases/conformance/node/index.cts(15,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. +tests/cases/conformance/node/index.cts(16,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. +tests/cases/conformance/node/index.cts(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. +tests/cases/conformance/node/index.cts(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. +tests/cases/conformance/node/index.cts(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. +tests/cases/conformance/node/index.cts(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.cts(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.cts(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.cts(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.cts(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -36,11 +36,11 @@ tests/cases/conformance/node/index.mts(21,22): error TS2835: Relative import pat tests/cases/conformance/node/index.mts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.mts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.mts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.mts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.mts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.mts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.mts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.mts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -63,11 +63,11 @@ tests/cases/conformance/node/index.ts(21,22): error TS2835: Relative import path tests/cases/conformance/node/index.ts(22,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.ts(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/index.ts(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? -tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/index.ts(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/index.ts(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/index.ts(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/index.ts(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -191,10 +191,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -203,13 +203,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -264,35 +264,35 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. import * as m12 from "./subfolder2/another/index.cjs"; // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) import * as m13 from "./"; ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. import * as m15 from "./subfolder"; import * as m16 from "./subfolder/"; import * as m17 from "./subfolder/index"; @@ -301,13 +301,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import * as m20 from "./subfolder2/index"; import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. void m1; void m2; void m3; @@ -335,10 +335,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -347,13 +347,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -477,10 +477,10 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path // These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!) import m24 = require("./"); ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); import m27 = require("./subfolder/"); import m28 = require("./subfolder/index"); @@ -489,13 +489,13 @@ tests/cases/conformance/node/index.ts(84,21): error TS2835: Relative import path import m31 = require("./subfolder2/index"); import m32 = require("./subfolder2/another"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt index 83c4abe3350ae..58a2647d59cc8 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node16).errors.txt @@ -1,18 +1,18 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. tests/cases/conformance/node/allowJs/index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -20,11 +20,11 @@ tests/cases/conformance/node/allowJs/index.cjs(56,1): error TS8002: 'import ... tests/cases/conformance/node/allowJs/index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -48,9 +48,9 @@ tests/cases/conformance/node/allowJs/index.js(22,22): error TS2834: Relative imp tests/cases/conformance/node/allowJs/index.js(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/allowJs/index.js(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -58,11 +58,11 @@ tests/cases/conformance/node/allowJs/index.js(55,1): error TS8002: 'import ... = tests/cases/conformance/node/allowJs/index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.js(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.js(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -86,9 +86,9 @@ tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2834: Relative im tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -96,11 +96,11 @@ tests/cases/conformance/node/allowJs/index.mjs(55,1): error TS8002: 'import ... tests/cases/conformance/node/allowJs/index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -226,12 +226,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -254,17 +254,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -318,35 +318,35 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. import * as m12 from "./subfolder2/another/index.cjs"; // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) import * as m13 from "./"; ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. import * as m15 from "./subfolder"; import * as m16 from "./subfolder/"; import * as m17 from "./subfolder/index"; @@ -355,13 +355,13 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im import * as m20 from "./subfolder2/index"; import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. void m1; void m2; void m3; @@ -391,12 +391,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -419,17 +419,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -555,12 +555,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -583,17 +583,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt index 83c4abe3350ae..58a2647d59cc8 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -1,18 +1,18 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(3,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(6,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(9,21): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(11,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(15,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. tests/cases/conformance/node/allowJs/index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -20,11 +20,11 @@ tests/cases/conformance/node/allowJs/index.cjs(56,1): error TS8002: 'import ... tests/cases/conformance/node/allowJs/index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.cjs(77,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -48,9 +48,9 @@ tests/cases/conformance/node/allowJs/index.js(22,22): error TS2834: Relative imp tests/cases/conformance/node/allowJs/index.js(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/allowJs/index.js(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.js(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -58,11 +58,11 @@ tests/cases/conformance/node/allowJs/index.js(55,1): error TS8002: 'import ... = tests/cases/conformance/node/allowJs/index.js(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.js(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.js(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.js(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -86,9 +86,9 @@ tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2834: Relative im tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './subfolder2/another/index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -96,11 +96,11 @@ tests/cases/conformance/node/allowJs/index.mjs(55,1): error TS8002: 'import ... tests/cases/conformance/node/allowJs/index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations. tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2835: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './index.mjs'? tests/cases/conformance/node/allowJs/index.mjs(76,21): error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path. @@ -226,12 +226,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -254,17 +254,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -318,35 +318,35 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.js")' call instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index.mjs")' call instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder/index.mjs")' call instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/index.mjs")' call instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.js")' call instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index.mjs")' call instead. import * as m12 from "./subfolder2/another/index.cjs"; // The next ones should _mostly_ work - cjs format files have index resolution and extension resolution (except for those which resolve to an esm format file) import * as m13 from "./"; ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./")' call instead. import * as m14 from "./index"; ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./index")' call instead. import * as m15 from "./subfolder"; import * as m16 from "./subfolder/"; import * as m17 from "./subfolder/index"; @@ -355,13 +355,13 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im import * as m20 from "./subfolder2/index"; import * as m21 from "./subfolder2/another"; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another")' call instead. import * as m22 from "./subfolder2/another/"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/")' call instead. import * as m23 from "./subfolder2/another/index"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./subfolder2/another/index")' call instead. void m1; void m2; void m3; @@ -391,12 +391,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -419,17 +419,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; @@ -555,12 +555,12 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~ -!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m25 = require("./index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~ -!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m26 = require("./subfolder"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. @@ -583,17 +583,17 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2835: Relative im ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m33 = require("./subfolder2/another/"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import m34 = require("./subfolder2/another/index"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. void m24; void m25; void m26; diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt index 904a471431877..f5b871b32e754 100644 --- a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. @@ -43,10 +43,10 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt index 904a471431877..f5b871b32e754 100644 --- a/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. @@ -43,10 +43,10 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt index 63e7af6ada0ac..376e4a9483b5e 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=node16).errors.txt @@ -1,10 +1,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -41,17 +41,17 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; cjsi; mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; @@ -81,7 +81,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt index 63e7af6ada0ac..376e4a9483b5e 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt @@ -1,10 +1,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -41,17 +41,17 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; cjsi; mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; @@ -81,7 +81,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt index ffbcbe24e9973..3f5cb24b8ba83 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -25,10 +25,10 @@ tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#typ import * as cjs from "#cjs"; import * as mjs from "#mjs"; ~~~~~~ -!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. import * as type from "#type"; ~~~~~~~ -!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt index ffbcbe24e9973..3f5cb24b8ba83 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. +tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'tests/cases/conformance/node/allowJs/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -25,10 +25,10 @@ tests/cases/conformance/node/allowJs/index.cjs(4,23): error TS1471: Module '#typ import * as cjs from "#cjs"; import * as mjs from "#mjs"; ~~~~~~ -!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. import * as type from "#type"; ~~~~~~~ -!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt index 0f1999477226b..9472951c04273 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=node16).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjsi from "inner/cjs/index"; import * as mjsi from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei from "inner/js/index"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt index 0f1999477226b..9472951c04273 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExports(module=nodenext).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjsi from "inner/cjs/index"; import * as mjsi from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei from "inner/js/index"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt index b989016f16abe..ab754b119d842 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. ==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjsi from "inner/cjs/index.cjs"; import * as mjsi from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as typei from "inner/js/index.js"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs/index.cjs"; import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt index b989016f16abe..ab754b119d842 100644 --- a/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.cjs(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. ==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjsi from "inner/cjs/index.cjs"; import * as mjsi from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as typei from "inner/js/index.js"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/allowJs/node_modules/inner/index.d.ts(3,22): error import * as cjs from "inner/cjs/index.cjs"; import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index c722192e6704e..7f392d707f582 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -11,12 +11,13 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs'. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; import mod2 = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -33,7 +34,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; import mod2 = require("./subfolder/index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt index c722192e6704e..7f392d707f582 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. -tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -11,12 +11,13 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs'. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; import mod2 = require("./index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -33,7 +34,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; import mod2 = require("./subfolder/index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt new file mode 100644 index 0000000000000..1b1e9d293be30 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt @@ -0,0 +1,28 @@ +/ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + + +==== /package.json (0 errors) ==== + {} + +==== /module.mts (0 errors) ==== + export {}; + +==== /tsExtension.ts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add `"type": "module"` to its package.json file with path '/package.json'. + +==== /jsExtension.js (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add `"type": "module"` to its package.json file with path '/package.json'. + +==== /ctsExtension.cts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt new file mode 100644 index 0000000000000..253c8c1c6fc59 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt @@ -0,0 +1,27 @@ +/ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + + +==== /package.json (0 errors) ==== + { "type": "commonjs" } + +==== /module.mts (0 errors) ==== + export {}; + +==== /tsExtension.ts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts'. + +==== /jsExtension.js (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs'. + +==== /ctsExtension.cts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt new file mode 100644 index 0000000000000..1af3c1d8ed4e6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt @@ -0,0 +1,19 @@ +/ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + + +==== /package.json (0 errors) ==== + { "type": "module" } + +==== /module.mts (0 errors) ==== + export {}; + +==== /tsExtension.ts (0 errors) ==== + import {} from "./module.mjs"; + +==== /jsExtension.js (0 errors) ==== + import {} from "./module.mjs"; + +==== /ctsExtension.cts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt new file mode 100644 index 0000000000000..03acd9f308d40 --- /dev/null +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt @@ -0,0 +1,24 @@ +/ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + + +==== /module.mts (0 errors) ==== + export {}; + +==== /tsExtension.ts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts'. + +==== /jsExtension.js (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs'. + +==== /ctsExtension.cts (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt index 793f3f03da25d..86b9f2304df77 100644 --- a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. @@ -43,10 +43,10 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt index 793f3f03da25d..86b9f2304df77 100644 --- a/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesConditionalPackageExports(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. @@ -43,10 +43,10 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt index 4ee7f3c4cef3d..d31427a694d02 100644 --- a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt @@ -1,11 +1,11 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/index.cts(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/node/node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. @@ -43,17 +43,17 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. export const a = cjs; export const b = mjs; export const c = type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; export const d = cjsi; export const e = mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; cjs; ~~~ @@ -87,7 +87,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; cjs; ~~~ diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt index 4ee7f3c4cef3d..d31427a694d02 100644 --- a/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt @@ -1,11 +1,11 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/index.cts(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. tests/cases/conformance/node/node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. @@ -43,17 +43,17 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. export const a = cjs; export const b = mjs; export const c = type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; export const d = cjsi; export const e = mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; cjs; ~~~ @@ -87,7 +87,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(5,1): error TS1036: S import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; cjs; ~~~ diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt index 8f7452ffa72aa..deca8a067190c 100644 --- a/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesPackageExports(module=node16).errors.txt @@ -1,10 +1,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/index.cts(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -41,17 +41,17 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; cjsi; mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; @@ -81,7 +81,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt index 8f7452ffa72aa..deca8a067190c 100644 --- a/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesPackageExports(module=nodenext).errors.txt @@ -1,10 +1,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(9,23): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. +tests/cases/conformance/node/index.cts(9,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'tests/cases/conformance/node/package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -41,17 +41,17 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "package/cjs"; import * as mjs from "package/mjs"; ~~~~~~~~~~~~~ -!!! error TS1471: Module 'package/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package/mjs")' call instead. import * as type from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. cjs; mjs; type; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as typei from "inner"; cjsi; mjsi; @@ -63,7 +63,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; @@ -81,7 +81,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs"; import * as mjs from "inner/mjs"; ~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs")' call instead. import * as type from "inner"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt index cc174f1eb7e26..64b8cd72b3a2a 100644 --- a/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesPackageImports(module=node16).errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -23,10 +23,10 @@ tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' canno import * as cjs from "#cjs"; import * as mjs from "#mjs"; ~~~~~~ -!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. import * as type from "#type"; ~~~~~~~ -!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt index cc174f1eb7e26..64b8cd72b3a2a 100644 --- a/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesPackageImports(module=nodenext).errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/node/index.cts(3,22): error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. +tests/cases/conformance/node/index.cts(4,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -23,10 +23,10 @@ tests/cases/conformance/node/index.cts(4,23): error TS1471: Module '#type' canno import * as cjs from "#cjs"; import * as mjs from "#mjs"; ~~~~~~ -!!! error TS1471: Module '#mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#mjs")' call instead. import * as type from "#type"; ~~~~~~~ -!!! error TS1471: Module '#type' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("#type")' call instead. cjs; mjs; type; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt index 0dc3774d5ef60..91d984d5e8f22 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=node16).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi from "inner/cjs/index"; import * as mjsi from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei from "inner/js/index"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt index 0dc3774d5ef60..91d984d5e8f22 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExports(module=nodenext).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi from "inner/cjs/index"; import * as mjsi from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei from "inner/js/index"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=node16).errors.txt index 863b455cf4796..5239d2aee995d 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=node16).errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.cts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.cts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. -tests/cases/conformance/node/index.cts(9,24): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(9,24): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.mts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.mts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. @@ -17,9 +17,9 @@ tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(4,23): error tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/index.ts (3 errors) ==== @@ -79,7 +79,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi2 from "inner/cjs/index"; import * as mjsi2 from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei2 from "inner/js/index"; cjsi2; mjsi2; @@ -133,7 +133,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -151,7 +151,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=nodenext).errors.txt index 863b455cf4796..5239d2aee995d 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsExclude(module=nodenext).errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.cts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.cts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. -tests/cases/conformance/node/index.cts(9,24): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(9,24): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/index.mts(2,23): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.mts(3,23): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/index.mts(4,24): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. @@ -17,9 +17,9 @@ tests/cases/conformance/node/node_modules/inner/exclude/index.d.mts(4,23): error tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(2,22): error TS2307: Cannot find module 'inner/cjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(3,22): error TS2307: Cannot find module 'inner/mjs/exclude/index' or its corresponding type declarations. tests/cases/conformance/node/node_modules/inner/exclude/index.d.ts(4,23): error TS2307: Cannot find module 'inner/js/exclude/index' or its corresponding type declarations. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. ==== tests/cases/conformance/node/index.ts (3 errors) ==== @@ -79,7 +79,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi2 from "inner/cjs/index"; import * as mjsi2 from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as typei2 from "inner/js/index"; cjsi2; mjsi2; @@ -133,7 +133,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; @@ -151,7 +151,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index"; import * as mjs from "inner/mjs/index"; ~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index")' call instead. import * as type from "inner/js/index"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt index 9aa041ab4186a..e9566d8bf5513 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=node16).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi from "inner/cjs/index.cjs"; import * as mjsi from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as typei from "inner/js/index.js"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index.cjs"; import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt index 9aa041ab4186a..e9566d8bf5513 100644 --- a/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesPackagePatternExportsTrailers(module=nodenext).errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/node/index.cts(3,23): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(3,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. +tests/cases/conformance/node/node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. tests/cases/conformance/node/node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjsi from "inner/cjs/index.cjs"; import * as mjsi from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as typei from "inner/js/index.js"; cjsi; mjsi; @@ -37,7 +37,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: !!! error TS2303: Circular definition of import alias 'cjs'. import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; @@ -55,7 +55,7 @@ tests/cases/conformance/node/node_modules/inner/index.d.ts(3,22): error TS1471: import * as cjs from "inner/cjs/index.cjs"; import * as mjs from "inner/mjs/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1471: Module 'inner/mjs/index.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("inner/mjs/index.mjs")' call instead. import * as type from "inner/js/index.js"; export { cjs }; export { mjs }; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt index 012ef390621c9..c126994fc3c04 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt @@ -1,16 +1,17 @@ -tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts'. import mod = require("../index.js"); ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; import mod2 = require("./index.js"); export async function f() { @@ -23,7 +24,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h as _h} from "./index.js"; import mod = require("./index.js"); ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; import mod2 = require("./subfolder/index.js"); export async function h() { diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt index 012ef390621c9..c126994fc3c04 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt @@ -1,16 +1,17 @@ -tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. -tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. +tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. ==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== // cjs format file import {h} from "../index.js"; ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. +!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts'. import mod = require("../index.js"); ~~~~~~~~~~~~~ -!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f as _f} from "./index.js"; import mod2 = require("./index.js"); export async function f() { @@ -23,7 +24,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h as _h} from "./index.js"; import mod = require("./index.js"); ~~~~~~~~~~~~ -!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. import {f} from "./subfolder/index.js"; import mod2 = require("./subfolder/index.js"); export async function h() { diff --git a/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt b/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt index c1573b8f51dd8..bc1836c35c755 100644 --- a/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt +++ b/tests/baselines/reference/nodePackageSelfName(module=node16).errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' can // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. self; ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt b/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt index c1573b8f51dd8..bc1836c35c755 100644 --- a/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodePackageSelfName(module=nodenext).errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS1471: Module 'package' can // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1471: Module 'package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("package")' call instead. self; ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt index b2a9f313de779..afda2813d6f4d 100644 --- a/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=node16).errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/node/index.cts(2,23): error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@scope/package")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS1471: Module '@scope/packa // cjs format file import * as self from "@scope/package"; ~~~~~~~~~~~~~~~~ -!!! error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@scope/package")' call instead. self; ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/nodePackageSelfNameScoped(module=nodenext).errors.txt b/tests/baselines/reference/nodePackageSelfNameScoped(module=nodenext).errors.txt index b2a9f313de779..afda2813d6f4d 100644 --- a/tests/baselines/reference/nodePackageSelfNameScoped(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodePackageSelfNameScoped(module=nodenext).errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/node/index.cts(2,23): error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +tests/cases/conformance/node/index.cts(2,23): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@scope/package")' call instead. ==== tests/cases/conformance/node/index.ts (0 errors) ==== @@ -13,7 +13,7 @@ tests/cases/conformance/node/index.cts(2,23): error TS1471: Module '@scope/packa // cjs format file import * as self from "@scope/package"; ~~~~~~~~~~~~~~~~ -!!! error TS1471: Module '@scope/package' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@scope/package")' call instead. self; ==== tests/cases/conformance/node/package.json (0 errors) ==== { diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index d0817d761e764..c4dbd6e97483c 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -315,12 +315,73 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~ -[12:01:16 AM] Found 1 error. Watching for file changes. + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +[12:01:16 AM] Found 6 errors. Watching for file changes. @@ -537,12 +598,73 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~ -[12:01:34 AM] Found 1 error. Watching for file changes. + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + + packages/pkg1/index.ts:1:29 + 1 import type { TheNum } from 'pkg2' +    ~~~~~~ + To convert this file to an ECMAScript module, change its file extension to '.mts'. + +[12:01:34 AM] Found 6 errors. Watching for file changes. diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts new file mode 100644 index 0000000000000..ca68ea6157ffb --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @noTypesAndSymbols: true +// @module: node16 +// @allowJs: true +// @checkJs: true + +// @Filename: /package.json +{} + +// @Filename: /module.mts +export {}; + +// @Filename: /tsExtension.ts +import {} from "./module.mjs"; + +// @Filename: /jsExtension.js +import {} from "./module.mjs"; + +// @Filename: /ctsExtension.cts +import {} from "./module.mjs"; diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts new file mode 100644 index 0000000000000..e3c9a7e212139 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @noTypesAndSymbols: true +// @module: node16 +// @allowJs: true +// @checkJs: true + +// @Filename: /package.json +{ "type": "commonjs" } + +// @Filename: /module.mts +export {}; + +// @Filename: /tsExtension.ts +import {} from "./module.mjs"; + +// @Filename: /jsExtension.js +import {} from "./module.mjs"; + +// @Filename: /ctsExtension.cts +import {} from "./module.mjs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts new file mode 100644 index 0000000000000..261c620516ff7 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts @@ -0,0 +1,20 @@ +// @noEmit: true +// @noTypesAndSymbols: true +// @module: node16 +// @allowJs: true +// @checkJs: true + +// @Filename: /package.json +{ "type": "module" } + +// @Filename: /module.mts +export {}; + +// @Filename: /tsExtension.ts +import {} from "./module.mjs"; + +// @Filename: /jsExtension.js +import {} from "./module.mjs"; + +// @Filename: /ctsExtension.cts +import {} from "./module.mjs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts new file mode 100644 index 0000000000000..d1792b0bac8e8 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts @@ -0,0 +1,17 @@ +// @noEmit: true +// @noTypesAndSymbols: true +// @module: node16 +// @allowJs: true +// @checkJs: true + +// @Filename: /module.mts +export {}; + +// @Filename: /tsExtension.ts +import {} from "./module.mjs"; + +// @Filename: /jsExtension.js +import {} from "./module.mjs"; + +// @Filename: /ctsExtension.cts +import {} from "./module.mjs"; \ No newline at end of file From b5e6ee5c170be3dc271d54ea41809524eba39752 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 29 Jul 2022 11:02:16 -0700 Subject: [PATCH 2/6] Update error message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f93b11710a53..462595909f1e7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3595,7 +3595,7 @@ namespace ts { if (scope && !scope.packageJsonContent.type) { addRelatedInfo(diag, createDiagnosticForNode( errorNode, - Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_type_Colon_module_to_its_package_json_file_with_path_1, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, combinePaths(scope.packageDirectory, "package.json"))); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index d08a2d6e44a23..34e04aafc2074 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1509,7 +1509,7 @@ "category": "Message", "code": 1480 }, - "To convert this file to an ECMAScript module, change its file extension to '{0}', or add `\"type\": \"module\"` to its package.json file with path '{1}'.": { + "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'.": { "category": "Message", "code": 1481 }, diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt index 1b1e9d293be30..dd9b6c1a3861c 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt @@ -13,13 +13,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add `"type": "module"` to its package.json file with path '/package.json'. +!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/package.json'. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add `"type": "module"` to its package.json file with path '/package.json'. +!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to '/package.json'. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; From 0313251bce659bd5501ea635f0d4c26f3d5feebb Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 3 Aug 2022 10:44:08 -0700 Subject: [PATCH 3/6] Use package scope from source file --- src/compiler/checker.ts | 2 +- src/compiler/program.ts | 1 - src/compiler/types.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index abad365f871a6..f58d97498d8f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3585,7 +3585,7 @@ namespace ts { const diag = error(errorNode, Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference); const ext = tryGetExtensionFromPath(currentSourceFile.fileName); if (ext === Extension.Ts || ext === Extension.Js) { - const scope = host.getPackageScopeForPath(currentSourceFile.path); + const scope = currentSourceFile.packageJsonScope; const targetExt = ext === Extension.Ts ? Extension.Mts : Extension.Mjs; if (scope && !scope.packageJsonContent.type) { addRelatedInfo(diag, createDiagnosticForNode( diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e8df21eb5efec..e7c0f363ea8df 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1340,7 +1340,6 @@ namespace ts { directoryExists, getSymlinkCache, realpath: host.realpath?.bind(host), - getPackageScopeForPath: path => getPackageScopeForPath(path, getTemporaryModuleResolutionState(moduleResolutionCache?.getPackageJsonInfoCache(), host, options)), useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), getFileIncludeReasons: () => fileReasons, structureIsReused, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c0d2764146599..2281c7dd06e9a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4355,7 +4355,6 @@ namespace ts { getResolvedTypeReferenceDirectives(): ModeAwareCache; getProjectReferenceRedirect(fileName: string): string | undefined; isSourceOfProjectReferenceRedirect(fileName: string): boolean; - getPackageScopeForPath(path: Path): PackageJsonInfo | undefined; readonly redirectTargetsMap: RedirectTargetsMap; } From b691612f193d85a617ff48a86cddfc077afa9422 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 3 Aug 2022 11:53:35 -0700 Subject: [PATCH 4/6] Update baselines --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- ...ronousCallErrors(module=node16).errors.txt | 2 +- ...nousCallErrors(module=nodenext).errors.txt | 2 +- ...SResolvingToESM2_cjsPackageJson.errors.txt | 4 +-- ...JSResolvingToESM4_noPackageJson.errors.txt | 4 +-- ...ronousCallErrors(module=node16).errors.txt | 2 +- ...nousCallErrors(module=nodenext).errors.txt | 2 +- ...t-correctly-with-cts-and-mts-extensions.js | 36 +++++++------------ ...en-package-json-with-type-module-exists.js | 8 ++--- .../package-json-file-is-edited.js | 6 ++-- 11 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f58d97498d8f3..3adea7394a441 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3597,7 +3597,7 @@ namespace ts { else { addRelatedInfo(diag, createDiagnosticForNode( errorNode, - Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt)); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 35eff919e9635..07c09853af671 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1521,7 +1521,7 @@ "category": "Error", "code": 1479 }, - "To convert this file to an ECMAScript module, change its file extension to '{0}'.": { + "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`.": { "category": "Message", "code": 1480 }, diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index 7f392d707f582..e9cb1edac1dd4 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -12,7 +12,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs'. +!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt index 7f392d707f582..e9cb1edac1dd4 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -12,7 +12,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs'. +!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt index 253c8c1c6fc59..5559468a5a16e 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt @@ -13,13 +13,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts'. +!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs'. +!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt index 03acd9f308d40..ea2e6d1214019 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt @@ -10,13 +10,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts'. +!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs'. +!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt index c126994fc3c04..cd30537c5bba7 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts'. +!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt index c126994fc3c04..cd30537c5bba7 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts'. +!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index c4dbd6e97483c..d5dff7dd802bc 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -315,12 +315,6 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. 1 import type { TheNum } from 'pkg2' @@ -329,7 +323,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -339,7 +333,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -349,7 +343,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -359,7 +353,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -369,7 +363,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -379,7 +373,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. [12:01:16 AM] Found 6 errors. Watching for file changes. @@ -598,12 +592,6 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. -File '/user/username/projects/myproject/packages/pkg1/package.json' exists according to earlier cached lookups. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. 1 import type { TheNum } from 'pkg2' @@ -612,7 +600,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -622,7 +610,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -632,7 +620,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -642,7 +630,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -652,7 +640,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. @@ -662,7 +650,7 @@ File '/user/username/projects/myproject/packages/pkg1/package.json' exists accor packages/pkg1/index.ts:1:29 1 import type { TheNum } from 'pkg2'    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts'. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. [12:01:34 AM] Found 6 errors. Watching for file changes. diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 7ac357703053c..7fc45b240ada9 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -136,7 +136,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -261,7 +261,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -325,7 +325,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -386,7 +386,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js index d4905362c6152..07afb7b6a2b54 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js @@ -203,7 +203,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -267,7 +267,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -380,7 +380,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"Module './fileB.mjs' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.","code":1471,"category":"error"}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: From 0d3dbb2a7feb78ed420bf82fbe93c93fe37a9fcd Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 4 Aug 2022 15:12:25 -0700 Subject: [PATCH 5/6] Issue error for JSX/TSX files --- src/compiler/checker.ts | 37 +++++++++++++------ src/compiler/diagnosticMessages.json | 8 ++++ ...esolvingToESM1_emptyPackageJson.errors.txt | 7 ++++ ...SResolvingToESM2_cjsPackageJson.errors.txt | 10 ++++- ...solvingToESM3_modulePackageJson.errors.txt | 6 ++- ...JSResolvingToESM4_noPackageJson.errors.txt | 10 ++++- ...ulesCJSResolvingToESM1_emptyPackageJson.ts | 4 ++ ...odulesCJSResolvingToESM2_cjsPackageJson.ts | 6 ++- ...lesCJSResolvingToESM3_modulePackageJson.ts | 6 ++- ...ModulesCJSResolvingToESM4_noPackageJson.ts | 6 ++- 10 files changed, 83 insertions(+), 17 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3adea7394a441..648bb8d7843f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3584,21 +3584,36 @@ namespace ts { // CJS file resolving to an ESM file const diag = error(errorNode, Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference); const ext = tryGetExtensionFromPath(currentSourceFile.fileName); - if (ext === Extension.Ts || ext === Extension.Js) { + if (ext === Extension.Ts || ext === Extension.Js || ext === Extension.Tsx || ext === Extension.Jsx) { const scope = currentSourceFile.packageJsonScope; - const targetExt = ext === Extension.Ts ? Extension.Mts : Extension.Mjs; + const targetExt = ext === Extension.Ts ? Extension.Mts : ext === Extension.Js ? Extension.Mjs : undefined; if (scope && !scope.packageJsonContent.type) { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, - Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, - targetExt, - combinePaths(scope.packageDirectory, "package.json"))); + if (targetExt) { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, + targetExt, + combinePaths(scope.packageDirectory, "package.json"))); + } + else { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, + combinePaths(scope.packageDirectory, "package.json"))); + } } else { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, - Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, - targetExt)); + if (targetExt) { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, + targetExt)); + } + else { + addRelatedInfo(diag, createDiagnosticForNode( + errorNode, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module)); + } } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 07c09853af671..45e2cde143ca8 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1529,6 +1529,14 @@ "category": "Message", "code": 1481 }, + "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'.": { + "category": "Message", + "code": 1482 + }, + "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`.": { + "category": "Message", + "code": 1483 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt index dd9b6c1a3861c..2addaf39ef49c 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt @@ -1,6 +1,7 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. ==== /package.json (0 errors) ==== @@ -25,4 +26,10 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + +==== /tsxExtension.tsx (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1482 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, add the field `"type": "module"` to '/package.json'. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt index 5559468a5a16e..06ba7be6e2c12 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt @@ -1,6 +1,7 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. ==== /package.json (0 errors) ==== @@ -24,4 +25,11 @@ ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + +==== /tsxExtension.tsx (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1483 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt index 1af3c1d8ed4e6..5a95dbced9d64 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM3_modulePackageJson.errors.txt @@ -16,4 +16,8 @@ ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + +==== /tsxExtension.tsx (0 errors) ==== + import {} from "./module.mjs"; + \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt index ea2e6d1214019..1a812ee70a927 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt @@ -1,6 +1,7 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +/tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. ==== /module.mts (0 errors) ==== @@ -21,4 +22,11 @@ ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. \ No newline at end of file +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + +==== /tsxExtension.tsx (1 errors) ==== + import {} from "./module.mjs"; + ~~~~~~~~~~~~~~ +!!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. +!!! related TS1483 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. + \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts index ca68ea6157ffb..df229c6582160 100644 --- a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM1_emptyPackageJson.ts @@ -3,6 +3,7 @@ // @module: node16 // @allowJs: true // @checkJs: true +// @jsx: preserve // @Filename: /package.json {} @@ -18,3 +19,6 @@ import {} from "./module.mjs"; // @Filename: /ctsExtension.cts import {} from "./module.mjs"; + +// @Filename: /tsxExtension.tsx +import {} from "./module.mjs"; diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts index e3c9a7e212139..74c609c5f9d91 100644 --- a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM2_cjsPackageJson.ts @@ -3,6 +3,7 @@ // @module: node16 // @allowJs: true // @checkJs: true +// @jsx: preserve // @Filename: /package.json { "type": "commonjs" } @@ -17,4 +18,7 @@ import {} from "./module.mjs"; import {} from "./module.mjs"; // @Filename: /ctsExtension.cts -import {} from "./module.mjs"; \ No newline at end of file +import {} from "./module.mjs"; + +// @Filename: /tsxExtension.tsx +import {} from "./module.mjs"; diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts index 261c620516ff7..1a11ae8121449 100644 --- a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM3_modulePackageJson.ts @@ -3,6 +3,7 @@ // @module: node16 // @allowJs: true // @checkJs: true +// @jsx: preserve // @Filename: /package.json { "type": "module" } @@ -17,4 +18,7 @@ import {} from "./module.mjs"; import {} from "./module.mjs"; // @Filename: /ctsExtension.cts -import {} from "./module.mjs"; \ No newline at end of file +import {} from "./module.mjs"; + +// @Filename: /tsxExtension.tsx +import {} from "./module.mjs"; diff --git a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts index d1792b0bac8e8..b8fdae850eb64 100644 --- a/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts +++ b/tests/cases/conformance/node/nodeModulesCJSResolvingToESM4_noPackageJson.ts @@ -3,6 +3,7 @@ // @module: node16 // @allowJs: true // @checkJs: true +// @jsx: preserve // @Filename: /module.mts export {}; @@ -14,4 +15,7 @@ import {} from "./module.mjs"; import {} from "./module.mjs"; // @Filename: /ctsExtension.cts -import {} from "./module.mjs"; \ No newline at end of file +import {} from "./module.mjs"; + +// @Filename: /tsxExtension.tsx +import {} from "./module.mjs"; From 330160b2ff2daffea89576df54092933e9392051 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 4 Aug 2022 15:47:24 -0700 Subject: [PATCH 6/6] Switch from related info to message chain --- src/compiler/checker.ts | 30 +++-- ...ronousCallErrors(module=node16).errors.txt | 3 +- ...nousCallErrors(module=nodenext).errors.txt | 3 +- ...esolvingToESM1_emptyPackageJson.errors.txt | 9 +- ...SResolvingToESM2_cjsPackageJson.errors.txt | 9 +- ...JSResolvingToESM4_noPackageJson.errors.txt | 9 +- ...ronousCallErrors(module=node16).errors.txt | 3 +- ...nousCallErrors(module=nodenext).errors.txt | 3 +- ...t-correctly-with-cts-and-mts-extensions.js | 116 +----------------- ...en-package-json-with-type-module-exists.js | 8 +- .../package-json-file-is-edited.js | 6 +- 11 files changed, 54 insertions(+), 145 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 648bb8d7843f9..1ee04dbaf10c2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3582,40 +3582,44 @@ namespace ts { } else { // CJS file resolving to an ESM file - const diag = error(errorNode, Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference); + let diagnosticDetails; const ext = tryGetExtensionFromPath(currentSourceFile.fileName); if (ext === Extension.Ts || ext === Extension.Js || ext === Extension.Tsx || ext === Extension.Jsx) { const scope = currentSourceFile.packageJsonScope; const targetExt = ext === Extension.Ts ? Extension.Mts : ext === Extension.Js ? Extension.Mjs : undefined; if (scope && !scope.packageJsonContent.type) { if (targetExt) { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, + diagnosticDetails = chainDiagnosticMessages( + /*details*/ undefined, Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, - combinePaths(scope.packageDirectory, "package.json"))); + combinePaths(scope.packageDirectory, "package.json")); } else { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, + diagnosticDetails = chainDiagnosticMessages( + /*details*/ undefined, Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, - combinePaths(scope.packageDirectory, "package.json"))); + combinePaths(scope.packageDirectory, "package.json")); } } else { if (targetExt) { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, + diagnosticDetails = chainDiagnosticMessages( + /*details*/ undefined, Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, - targetExt)); + targetExt); } else { - addRelatedInfo(diag, createDiagnosticForNode( - errorNode, - Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module)); + diagnosticDetails = chainDiagnosticMessages( + /*details*/ undefined, + Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); } } } + diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, chainDiagnosticMessages( + diagnosticDetails, + Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, + moduleReference))); } } } diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt index e9cb1edac1dd4..f3f58f404639c 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node16).errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -12,7 +13,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt index e9cb1edac1dd4..f3f58f404639c 100644 --- a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' tests/cases/conformance/node/allowJs/index.js(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. @@ -12,7 +13,7 @@ tests/cases/conformance/node/allowJs/subfolder/index.js(5,1): error TS8002: 'imp import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/allowJs/subfolder/index.js:2:17: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS8002: 'import ... =' can only be used in TypeScript files. diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt index 2addaf39ef49c..fe0dbb5d5b82d 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM1_emptyPackageJson.errors.txt @@ -1,7 +1,10 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to '/package.json'. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/package.json'. /tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, add the field `"type": "module"` to '/package.json'. ==== /package.json (0 errors) ==== @@ -14,13 +17,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1481 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/package.json'. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/package.json'. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1481 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to '/package.json'. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs', or add the field `"type": "module"` to '/package.json'. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; @@ -31,5 +34,5 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1482 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, add the field `"type": "module"` to '/package.json'. +!!! error TS1479: To convert this file to an ECMAScript module, add the field `"type": "module"` to '/package.json'. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt index 06ba7be6e2c12..c8a14545ae151 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM2_cjsPackageJson.errors.txt @@ -1,7 +1,10 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. /tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. ==== /package.json (0 errors) ==== @@ -14,13 +17,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; @@ -31,5 +34,5 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1483 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt index 1a812ee70a927..14af0e2900cd3 100644 --- a/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt +++ b/tests/baselines/reference/nodeModulesCJSResolvingToESM4_noPackageJson.errors.txt @@ -1,7 +1,10 @@ /ctsExtension.cts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. /jsExtension.js(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. /tsExtension.ts(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. /tsxExtension.tsx(1,16): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. + To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. ==== /module.mts (0 errors) ==== @@ -11,13 +14,13 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /tsExtension.ts:1:16: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. ==== /jsExtension.js (1 errors) ==== import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1480 /jsExtension.js:1:16: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mjs' or create a local package.json file with `{ "type": "module" }`. ==== /ctsExtension.cts (1 errors) ==== import {} from "./module.mjs"; @@ -28,5 +31,5 @@ import {} from "./module.mjs"; ~~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./module.mjs")' call instead. -!!! related TS1483 /tsxExtension.tsx:1:16: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, create a local package.json file with `{ "type": "module" }`. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt index cd30537c5bba7..e64d68f570108 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node16).errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. @@ -8,7 +9,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt index cd30537c5bba7..e64d68f570108 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/node/index.ts(3,22): error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. tests/cases/conformance/node/subfolder/index.ts(2,17): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. @@ -8,7 +9,7 @@ tests/cases/conformance/node/subfolder/index.ts(3,22): error TS1471: Module '../ import {h} from "../index.js"; ~~~~~~~~~~~~~ !!! error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead. -!!! related TS1480 tests/cases/conformance/node/subfolder/index.ts:2:17: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. +!!! error TS1479: To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. import mod = require("../index.js"); ~~~~~~~~~~~~~ !!! error TS1471: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead. diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index d5dff7dd802bc..a59b6a3e2637f 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -316,66 +316,12 @@ File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. 1 import type { TheNum } from 'pkg2'    ~~~~~~ - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -[12:01:16 AM] Found 6 errors. Watching for file changes. +[12:01:16 AM] Found 1 error. Watching for file changes. @@ -593,66 +539,12 @@ File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. + To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. 1 import type { TheNum } from 'pkg2'    ~~~~~~ - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -packages/pkg1/index.ts:1:29 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("pkg2")' call instead. - -1 import type { TheNum } from 'pkg2' -   ~~~~~~ - - packages/pkg1/index.ts:1:29 - 1 import type { TheNum } from 'pkg2' -    ~~~~~~ - To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`. - -[12:01:34 AM] Found 6 errors. Watching for file changes. +[12:01:34 AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 7fc45b240ada9..4394f0a610f9d 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -136,7 +136,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -261,7 +261,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -325,7 +325,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -386,7 +386,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js index 07afb7b6a2b54..2761d4dd8de0d 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js @@ -203,7 +203,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","category":"message","code":1481}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -267,7 +267,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: @@ -380,7 +380,7 @@ response:{"responseRequired":false} event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: - {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]},{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.","code":1479,"category":"error","relatedInformation":[{"span":{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"file":"/user/username/projects/myproject/src/fileA.ts"},"message":"To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","category":"message","code":1480}]}]}} + {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} event: