From 6108eb8ccdbe4af4d0fcf6c39a28805dba13603d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 17:19:51 -0700 Subject: [PATCH 01/16] wip --- internal/module/resolver.go | 165 +++++++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 1 deletion(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index d054c1846d..98ec64585c 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/semver" "github.com/microsoft/typescript-go/internal/tspath" @@ -748,10 +749,172 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio } func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string, packagePath string, isImports bool) *resolved { - // !!! + // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir + // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure + // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! + // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). + // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. + if !r.isConfigLookup && + (r.compilerOptions.DeclarationDir != "" || r.compilerOptions.OutDir != "") && + !strings.Contains(finalPath, "/node_modules/") && + (r.compilerOptions.ConfigFilePath == "" || tspath.ContainsPath( + tspath.GetDirectoryPath(packagePath), + r.compilerOptions.ConfigFilePath, + tspath.ComparePathsOptions{ + UseCaseSensitiveFileNames: r.resolver.host.FS().UseCaseSensitiveFileNames(), + CurrentDirectory: r.resolver.host.GetCurrentDirectory(), + }, + )) { + // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. + // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) + // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) + + useCaseSensitiveFileNames := r.resolver.host.FS().UseCaseSensitiveFileNames() + var commonSourceDirGuesses []string + + // A `rootDir` compiler option strongly indicates the root location + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + if r.compilerOptions.RootDir != "" || (r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "") { + commonDir := tspath.GetNormalizedAbsolutePath(r.getCommonSourceDirectory(), r.resolver.host.GetCurrentDirectory()) + commonSourceDirGuesses = append(commonSourceDirGuesses, commonDir) + } else if r.containingDirectory != "" { + // However without either of those set we're in the dark. Let's say you have + // + // ./tools/index.ts + // ./src/index.ts + // ./dist/index.js + // ./package.json <-- references ./dist/index.js + // ./tsconfig.json <-- loads ./src/index.ts + // + // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? + // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from + // without more context. + // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too + // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.containingDirectory + + requestingFile := tspath.GetNormalizedAbsolutePath(tspath.CombinePaths(r.containingDirectory, "index.ts"), r.resolver.host.GetCurrentDirectory()) + // And we can try every folder above the common folder for the request folder and the config/package base directory + // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't + // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything + // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then + // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup + // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all + // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. + commonDir := tspath.GetNormalizedAbsolutePath(r.getCommonSourceDirectoryForFiles([]string{requestingFile, tspath.GetNormalizedAbsolutePath(packagePath, r.resolver.host.GetCurrentDirectory())}), r.resolver.host.GetCurrentDirectory()) + commonSourceDirGuesses = append(commonSourceDirGuesses, commonDir) + + fragment := tspath.EnsureTrailingDirectorySeparator(commonDir) + for len(fragment) > 1 { + parts := tspath.GetPathComponents(fragment, "") + if len(parts) <= 1 { + break + } + parts = parts[:len(parts)-1] // remove a directory + commonDir := tspath.GetPathFromPathComponents(parts) + commonSourceDirGuesses = append([]string{commonDir}, commonSourceDirGuesses...) // unshift + fragment = tspath.EnsureTrailingDirectorySeparator(commonDir) + } + } + + if len(commonSourceDirGuesses) > 1 { + var diagnostic *ast.Diagnostic + if isImports { + diagnostic = ast.NewDiagnostic( + nil, + core.TextRange{}, + diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, + core.IfElse(entry == "", ".", entry), // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath, + ) + } else { + diagnostic = ast.NewDiagnostic( + nil, + core.TextRange{}, + diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, + core.IfElse(entry == "", ".", entry), + packagePath, + ) + } + r.diagnostics = append(r.diagnostics, *diagnostic) + } + + for _, commonSourceDirGuess := range commonSourceDirGuesses { + candidateDirectories := r.getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) + for _, candidateDir := range candidateDirectories { + if tspath.ContainsPath(candidateDir, finalPath, tspath.ComparePathsOptions{ + UseCaseSensitiveFileNames: useCaseSensitiveFileNames, + CurrentDirectory: r.resolver.host.GetCurrentDirectory(), + }) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + pathFragment := finalPath[len(candidateDir)+1:] // +1 to also remove directory separator + possibleInputBase := tspath.CombinePaths(commonSourceDirGuess, pathFragment) + jsAndDtsExtensions := []string{tspath.ExtensionMjs, tspath.ExtensionCjs, tspath.ExtensionJs, tspath.ExtensionJson, tspath.ExtensionDmts, tspath.ExtensionDcts, tspath.ExtensionDts} + for _, ext := range jsAndDtsExtensions { + if tspath.FileExtensionIs(possibleInputBase, ext) { + inputExts := r.getPossibleOriginalInputExtensionForExtension(possibleInputBase) + for _, possibleExt := range inputExts { + if !extensionIsOk(r.extensions, possibleExt) { + continue + } + possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) + if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { + return r.loadFileNameFromPackageJSONField(r.extensions, possibleInputWithInputExtension, "", false) + } + } + } + } + } + } + } + } return continueSearching() } +func (r *resolutionState) getCommonSourceDirectory() string { + return outputpaths.GetCommonSourceDirectory( + r.compilerOptions, + func() []string { return []string{} }, // Empty files function for now + r.resolver.host.GetCurrentDirectory(), + r.resolver.host.FS().UseCaseSensitiveFileNames(), + ) +} + +func (r *resolutionState) getCommonSourceDirectoryForFiles(files []string) string { + return outputpaths.GetCommonSourceDirectory( + r.compilerOptions, + func() []string { return files }, + r.resolver.host.GetCurrentDirectory(), + r.resolver.host.FS().UseCaseSensitiveFileNames(), + ) +} + +func (r *resolutionState) getOutputDirectoriesForBaseDirectory(commonSourceDirGuess string) []string { + // Config file output paths are processed to be relative to the host's current directory, while + // otherwise the paths are resolved relative to the common source dir the compiler puts together + currentDir := core.IfElse(r.compilerOptions.ConfigFilePath != "", r.resolver.host.GetCurrentDirectory(), commonSourceDirGuess) + var candidateDirectories []string + if r.compilerOptions.DeclarationDir != "" { + candidateDirectories = append(candidateDirectories, tspath.GetNormalizedAbsolutePath(tspath.CombinePaths(currentDir, r.compilerOptions.DeclarationDir), r.resolver.host.GetCurrentDirectory())) + } + if r.compilerOptions.OutDir != "" && r.compilerOptions.OutDir != r.compilerOptions.DeclarationDir { + candidateDirectories = append(candidateDirectories, tspath.GetNormalizedAbsolutePath(tspath.CombinePaths(currentDir, r.compilerOptions.OutDir), r.resolver.host.GetCurrentDirectory())) + } + return candidateDirectories +} + +func (r *resolutionState) getPossibleOriginalInputExtensionForExtension(path string) []string { + if tspath.FileExtensionIsOneOf(path, []string{tspath.ExtensionDmts, tspath.ExtensionMjs, tspath.ExtensionMts}) { + return []string{tspath.ExtensionMts, tspath.ExtensionMjs} + } + if tspath.FileExtensionIsOneOf(path, []string{tspath.ExtensionDcts, tspath.ExtensionCjs, tspath.ExtensionCts}) { + return []string{tspath.ExtensionCts, tspath.ExtensionCjs} + } + if tspath.FileExtensionIs(path, ".d.json.ts") { + return []string{tspath.ExtensionJson} + } + return []string{tspath.ExtensionTsx, tspath.ExtensionTs, tspath.ExtensionJsx, tspath.ExtensionJs} +} + func (r *resolutionState) loadModuleFromNearestNodeModulesDirectory(typesScopeOnly bool) *resolved { mode := core.ResolutionModeCommonJS if r.esmMode || r.conditionMatches("import") { From 11eac90c807cd6880076c754eff39797c3eea397 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 17:26:21 -0700 Subject: [PATCH 02/16] wow --- internal/module/resolver.go | 9 ++- ...nodeNextPackageImportMapRootDir.errors.txt | 23 ------- ...extPackageImportMapRootDir.errors.txt.diff | 27 --------- .../nodeNextPackageImportMapRootDir.symbols | 2 + ...deNextPackageImportMapRootDir.symbols.diff | 12 ---- .../nodeNextPackageImportMapRootDir.types | 10 ++-- ...nodeNextPackageImportMapRootDir.types.diff | 21 ------- ...deNextPackageSelfNameWithOutDir.errors.txt | 20 ------- ...tPackageSelfNameWithOutDir.errors.txt.diff | 32 +++++----- .../nodeNextPackageSelfNameWithOutDir.symbols | 2 + ...NextPackageSelfNameWithOutDir.symbols.diff | 12 ---- .../nodeNextPackageSelfNameWithOutDir.types | 10 ++-- ...deNextPackageSelfNameWithOutDir.types.diff | 21 ------- ...ackageSelfNameWithOutDirDeclDir.errors.txt | 23 ------- ...eSelfNameWithOutDirDeclDir.errors.txt.diff | 35 +++++------ ...xtPackageSelfNameWithOutDirDeclDir.symbols | 2 + ...kageSelfNameWithOutDirDeclDir.symbols.diff | 12 ---- ...NextPackageSelfNameWithOutDirDeclDir.types | 10 ++-- ...ackageSelfNameWithOutDirDeclDir.types.diff | 21 ------- ...fNameWithOutDirDeclDirComposite.errors.txt | 32 ---------- ...WithOutDirDeclDirComposite.errors.txt.diff | 36 ----------- ...SelfNameWithOutDirDeclDirComposite.symbols | 2 + ...ameWithOutDirDeclDirComposite.symbols.diff | 12 ---- ...geSelfNameWithOutDirDeclDirComposite.types | 10 ++-- ...fNameWithOutDirDeclDirComposite.types.diff | 21 ------- ...utDirDeclDirCompositeNestedDirs.errors.txt | 42 ------------- ...DeclDirCompositeNestedDirs.errors.txt.diff | 46 -------------- ...thOutDirDeclDirCompositeNestedDirs.symbols | 2 + ...DirDeclDirCompositeNestedDirs.symbols.diff | 2 + ...WithOutDirDeclDirCompositeNestedDirs.types | 10 ++-- ...utDirDeclDirCompositeNestedDirs.types.diff | 21 ------- ...NameWithOutDirDeclDirNestedDirs.errors.txt | 42 ------------- ...ithOutDirDeclDirNestedDirs.errors.txt.diff | 60 ++++++++++++------- ...elfNameWithOutDirDeclDirNestedDirs.symbols | 2 + ...meWithOutDirDeclDirNestedDirs.symbols.diff | 2 + ...eSelfNameWithOutDirDeclDirNestedDirs.types | 10 ++-- ...NameWithOutDirDeclDirNestedDirs.types.diff | 21 ------- ...elfNameWithOutDirDeclDirRootDir.errors.txt | 23 ------- ...meWithOutDirDeclDirRootDir.errors.txt.diff | 27 --------- ...geSelfNameWithOutDirDeclDirRootDir.symbols | 2 + ...fNameWithOutDirDeclDirRootDir.symbols.diff | 12 ---- ...kageSelfNameWithOutDirDeclDirRootDir.types | 10 ++-- ...elfNameWithOutDirDeclDirRootDir.types.diff | 21 ------- ...ackageSelfNameWithOutDirRootDir.errors.txt | 20 ------- ...eSelfNameWithOutDirRootDir.errors.txt.diff | 24 -------- ...xtPackageSelfNameWithOutDirRootDir.symbols | 2 + ...kageSelfNameWithOutDirRootDir.symbols.diff | 12 ---- ...NextPackageSelfNameWithOutDirRootDir.types | 10 ++-- ...ackageSelfNameWithOutDirRootDir.types.diff | 21 ------- ...selfNameAndImportsEmitInclusion.errors.txt | 38 ------------ ...ameAndImportsEmitInclusion.errors.txt.diff | 42 ------------- .../selfNameAndImportsEmitInclusion.js | 2 + .../selfNameAndImportsEmitInclusion.js.diff | 11 ---- .../nodeAllowJsPackageSelfName2.errors.txt | 44 ++++++++++++++ .../nodeAllowJsPackageSelfName2.symbols | 4 -- .../nodeAllowJsPackageSelfName2.symbols.diff | 10 ---- .../nodeAllowJsPackageSelfName2.types | 6 +- ...odeAllowJsPackageSelfName2.errors.txt.diff | 48 +++++++++++++++ .../nodeAllowJsPackageSelfName2.types.diff | 12 ++-- 59 files changed, 238 insertions(+), 840 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 98ec64585c..da52af4777 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -858,7 +858,14 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string } possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { - return r.loadFileNameFromPackageJSONField(r.extensions, possibleInputWithInputExtension, "", false) + if path, ok := r.tryFile(possibleInputWithInputExtension, false); ok { + extension := tspath.TryExtractTSExtension(path) + return &resolved{ + path: path, + extension: extension, + resolvedUsingTsExtension: false, // These are input files, not output files accessed with TS extensions + } + } } } } diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt deleted file mode 100644 index 6bb8c026ab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '#dep' or its corresponding type declarations. - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": "./dist/index.js" - }, - "imports": { - "#dep": "./dist/index.js" - } - } -==== index.ts (1 errors) ==== - import * as me from "#dep"; - ~~~~~~ -!!! error TS2307: Cannot find module '#dep' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt.diff deleted file mode 100644 index b42c3c0180..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.nodeNextPackageImportMapRootDir.errors.txt -+++ new.nodeNextPackageImportMapRootDir.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.ts(1,21): error TS2307: Cannot find module '#dep' or its corresponding type declarations. -+ -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": "./dist/index.js" -+ }, -+ "imports": { -+ "#dep": "./dist/index.js" -+ } -+ } -+==== index.ts (1 errors) ==== -+ import * as me from "#dep"; -+ ~~~~~~ -+!!! error TS2307: Cannot find module '#dep' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function thing(): void {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols index ea09e721ee..5d268641a1 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols @@ -5,7 +5,9 @@ import * as me from "#dep"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols.diff deleted file mode 100644 index d23bac478d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageImportMapRootDir.symbols -+++ new.nodeNextPackageImportMapRootDir.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types index b68e652012..12c154766e 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "#dep"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types.diff deleted file mode 100644 index 900c137968..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageImportMapRootDir.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageImportMapRootDir.types -+++ new.nodeNextPackageImportMapRootDir.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "#dep"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt deleted file mode 100644 index 67aff83133..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": "./dist/index.js" - } - } -==== index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff index cc3c7951f6..35abf0463b 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff @@ -5,21 +5,19 @@ - - -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ - ==== package.json (0 errors) ==== - { - "name": "@this/package", -@@= skipped -9, +8 lines =@@ - ".": "./dist/index.js" - } - } +-==== package.json (0 errors) ==== +- { +- "name": "@this/package", +- "type": "module", +- "exports": { +- ".": "./dist/index.js" +- } +- } -==== index.ts (0 errors) ==== -+==== index.ts (1 errors) ==== - import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - \ No newline at end of file +- import * as me from "@this/package"; +- +- me.thing(); +- +- export function thing(): void {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols index a7fc4e2e1d..80a238b132 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff deleted file mode 100644 index 81059b55c0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDir.symbols -+++ new.nodeNextPackageSelfNameWithOutDir.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types index 4d89d8bd8b..5b7de921ad 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff deleted file mode 100644 index 9e8fc2da9e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDir.types -+++ new.nodeNextPackageSelfNameWithOutDir.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt deleted file mode 100644 index c717ff4c92..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } -==== index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff index 6d0833fe41..d46f6efd9d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff @@ -5,21 +5,22 @@ - - -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ - ==== package.json (0 errors) ==== - { - "name": "@this/package", -@@= skipped -12, +11 lines =@@ - } - } - } +-==== package.json (0 errors) ==== +- { +- "name": "@this/package", +- "type": "module", +- "exports": { +- ".": { +- "default": "./dist/index.js", +- "types": "./types/index.d.ts" +- } +- } +- } -==== index.ts (0 errors) ==== -+==== index.ts (1 errors) ==== - import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - \ No newline at end of file +- import * as me from "@this/package"; +- +- me.thing(); +- +- export function thing(): void {} +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols index 9f75119c4a..23b246200c 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff deleted file mode 100644 index 6fa4367955..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDir.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDir.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types index 5ab49769a5..eb6b45ec9c 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff deleted file mode 100644 index d04e9b6454..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDir.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDir.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt deleted file mode 100644 index 94d98a813d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "composite": true - } - } -==== index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff deleted file mode 100644 index 7d11a0b922..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "outDir": "./dist", -+ "declarationDir": "./types", -+ "composite": true -+ } -+ } -+==== index.ts (1 errors) ==== -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function thing(): void {} -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": { -+ "default": "./dist/index.js", -+ "types": "./types/index.d.ts" -+ } -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols index fad765ba6f..12f74f2167 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff deleted file mode 100644 index ac6c21f8ef..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types index 0312d872ba..a4654ce72c 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff deleted file mode 100644 index 5b1a188279..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt deleted file mode 100644 index 78b1581d01..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt +++ /dev/null @@ -1,42 +0,0 @@ -src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "composite": true - } - } -==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` - // (the harness is wierd here in that noImplicitReferences makes only - // this file get loaded as an entrypoint and emitted, while on the - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function srcthing(): void {} - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff deleted file mode 100644 index 4b52c81320..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff +++ /dev/null @@ -1,46 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "outDir": "./dist", -+ "declarationDir": "./types", -+ "composite": true -+ } -+ } -+==== index.ts (0 errors) ==== -+ export {srcthing as thing} from "./src/thing.js"; -+==== src/thing.ts (1 errors) ==== -+ // The following import should cause `index.ts` -+ // to be included in the build, which will, -+ // in turn, cause the common src directory to not be `src` -+ // (the harness is wierd here in that noImplicitReferences makes only -+ // this file get loaded as an entrypoint and emitted, while on the -+ // real command-line we'll crawl the imports for that set - a limitation -+ // of the harness, I suppose) -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function srcthing(): void {} -+ -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": { -+ "default": "./dist/index.js", -+ "types": "./types/index.d.ts" -+ } -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols index 8325dd2aef..0aca3867f1 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols @@ -17,7 +17,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) +>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff index c477bfdd8e..a28cda674e 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff @@ -5,8 +5,10 @@ me.thing(); ->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) ++>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) ++>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types index 21e392eb8b..d65e7900aa 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff deleted file mode 100644 index f353a36a66..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types -@@= skipped -13, +13 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function srcthing(): void {} - >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt deleted file mode 100644 index d253a0fa23..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +++ /dev/null @@ -1,42 +0,0 @@ -src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "declaration": true - } - } -==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` - // (the harness is wierd here in that noImplicitReferences makes only - // this file get loaded as an entrypoint and emitted, while on the - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function srcthing(): void {} - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff index 331017e8ed..ba75c52cb2 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff @@ -5,27 +5,41 @@ - - -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ - ==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { -@@= skipped -12, +11 lines =@@ - } - ==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; +-==== tsconfig.json (0 errors) ==== +- { +- "compilerOptions": { +- "module": "nodenext", +- "outDir": "./dist", +- "declarationDir": "./types", +- "declaration": true +- } +- } +-==== index.ts (0 errors) ==== +- export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (0 errors) ==== -+==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` -@@= skipped -9, +9 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - \ No newline at end of file +- // The following import should cause `index.ts` +- // to be included in the build, which will, +- // in turn, cause the common src directory to not be `src` +- // (the harness is wierd here in that noImplicitReferences makes only +- // this file get loaded as an entrypoint and emitted, while on the +- // real command-line we'll crawl the imports for that set - a limitation +- // of the harness, I suppose) +- import * as me from "@this/package"; +- +- me.thing(); +- +- export function srcthing(): void {} +- +- +-==== package.json (0 errors) ==== +- { +- "name": "@this/package", +- "type": "module", +- "exports": { +- ".": { +- "default": "./dist/index.js", +- "types": "./types/index.d.ts" +- } +- } +- } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols index 0cd32d19d7..f4d32f11a9 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols @@ -17,7 +17,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) +>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff index 2d5893b203..a622e73c4d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff @@ -5,8 +5,10 @@ me.thing(); ->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) ++>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) ++>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types index fa5240b00c..fe50376388 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff deleted file mode 100644 index 6ad9c105ab..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types -@@= skipped -13, +13 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function srcthing(): void {} - >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt deleted file mode 100644 index b061751a7d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt +++ /dev/null @@ -1,23 +0,0 @@ -/pkg/src/index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== /pkg/package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } -==== /pkg/src/index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt.diff deleted file mode 100644 index 4fc7bb5161..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/pkg/src/index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== /pkg/package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": { -+ "default": "./dist/index.js", -+ "types": "./types/index.d.ts" -+ } -+ } -+ } -+==== /pkg/src/index.ts (1 errors) ==== -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function thing(): void {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols index aa0693e551..e39890387d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols.diff deleted file mode 100644 index a45d9af058..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types index 23598d5833..08aab042b7 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types @@ -2,13 +2,13 @@ === /pkg/src/index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types.diff deleted file mode 100644 index 3aeeb74b2d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirRootDir.types -@@= skipped -1, +1 lines =@@ - - === /pkg/src/index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt deleted file mode 100644 index 67aff83133..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": "./dist/index.js" - } - } -==== index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt.diff deleted file mode 100644 index e291447b20..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirRootDir.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirRootDir.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": "./dist/index.js" -+ } -+ } -+==== index.ts (1 errors) ==== -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function thing(): void {} -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols index 92e460ce36..8374eeed78 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols.diff deleted file mode 100644 index 7f60766aaf..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirRootDir.symbols -+++ new.nodeNextPackageSelfNameWithOutDirRootDir.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types index 68b55b6266..22d6d440c5 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types.diff deleted file mode 100644 index 72dfaaad3a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirRootDir.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirRootDir.types -+++ new.nodeNextPackageSelfNameWithOutDirRootDir.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt b/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt deleted file mode 100644 index 988844a868..0000000000 --- a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt +++ /dev/null @@ -1,38 +0,0 @@ -/src/main.ts(2,27): error TS2307: Cannot find module 'pkg/indirect2.js' or its corresponding type declarations. - - -==== /tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "dist", - "rootDir": "src", - }, - "files": ["src/main.ts"] - } - -==== /src/main.ts (1 errors) ==== - import { indirect1 } from "#indirect1"; - import { indirect2 } from "pkg/indirect2.js"; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module 'pkg/indirect2.js' or its corresponding type declarations. - console.log(indirect1, indirect2); - -==== /package.json (0 errors) ==== - { - "name": "pkg", - "type": "module", - "imports": { - "#indirect1": "./src/indirect1.ts" - }, - "exports": { - "./*": "./dist/*" - } - } - -==== /src/indirect1.ts (0 errors) ==== - export const indirect1 = 0; - -==== /src/indirect2.ts (0 errors) ==== - export const indirect2 = 0; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt.diff deleted file mode 100644 index bc3a93722f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.errors.txt.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.selfNameAndImportsEmitInclusion.errors.txt -+++ new.selfNameAndImportsEmitInclusion.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/src/main.ts(2,27): error TS2307: Cannot find module 'pkg/indirect2.js' or its corresponding type declarations. -+ -+ -+==== /tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "outDir": "dist", -+ "rootDir": "src", -+ }, -+ "files": ["src/main.ts"] -+ } -+ -+==== /src/main.ts (1 errors) ==== -+ import { indirect1 } from "#indirect1"; -+ import { indirect2 } from "pkg/indirect2.js"; -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module 'pkg/indirect2.js' or its corresponding type declarations. -+ console.log(indirect1, indirect2); -+ -+==== /package.json (0 errors) ==== -+ { -+ "name": "pkg", -+ "type": "module", -+ "imports": { -+ "#indirect1": "./src/indirect1.ts" -+ }, -+ "exports": { -+ "./*": "./dist/*" -+ } -+ } -+ -+==== /src/indirect1.ts (0 errors) ==== -+ export const indirect1 = 0; -+ -+==== /src/indirect2.ts (0 errors) ==== -+ export const indirect2 = 0; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js b/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js index 15f62d8d28..e8e1e014ab 100644 --- a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js +++ b/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js @@ -26,6 +26,8 @@ console.log(indirect1, indirect2); //// [indirect1.js] export const indirect1 = 0; +//// [indirect2.js] +export const indirect2 = 0; //// [main.js] import { indirect1 } from "#indirect1"; import { indirect2 } from "pkg/indirect2.js"; diff --git a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js.diff b/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js.diff deleted file mode 100644 index 94915b9bc2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/selfNameAndImportsEmitInclusion.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.selfNameAndImportsEmitInclusion.js -+++ new.selfNameAndImportsEmitInclusion.js -@@= skipped -25, +25 lines =@@ - - //// [indirect1.js] - export const indirect1 = 0; --//// [indirect2.js] --export const indirect2 = 0; - //// [main.js] - import { indirect1 } from "#indirect1"; - import { indirect2 } from "pkg/indirect2.js"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt new file mode 100644 index 0000000000..8298b0435a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt @@ -0,0 +1,44 @@ +/test/foo.js(1,21): error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. + + +==== /tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "module": "nodenext", + "target": "esnext", + "emitDeclarationOnly": true, + "declaration": true, + "declarationDir": "./types", + "checkJs": true, + "rootDir": ".", + "strict": true, + }, + "include": ["src", "test"] + } + +==== /src/foo.js (0 errors) ==== + export const foo = 1; + +==== /test/foo.js (1 errors) ==== + import { foo } from "js-self-name-import/foo.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. + +==== /package.json (0 errors) ==== + { + "name": "js-self-name-import", + "type": "module", + "exports": { + "./*": { + "types": "./types/src/*", + "default": "./src/*" + } + } + } + +==== /types/src/foo.d.ts (0 errors) ==== + export const foo: 1; + +==== /types/test/foo.d.ts (0 errors) ==== + export {}; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols index 236a605968..cf553ecca4 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols @@ -8,7 +8,3 @@ export const foo = 1; import { foo } from "js-self-name-import/foo.js"; >foo : Symbol(foo, Decl(foo.js, 0, 8)) -=== /types/src/foo.d.ts === -export const foo: 1; ->foo : Symbol(foo, Decl(foo.d.ts, 0, 12)) - diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols.diff b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols.diff deleted file mode 100644 index d78f58e9f7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.symbols.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.nodeAllowJsPackageSelfName2.symbols -+++ new.nodeAllowJsPackageSelfName2.symbols -@@= skipped -7, +7 lines =@@ - import { foo } from "js-self-name-import/foo.js"; - >foo : Symbol(foo, Decl(foo.js, 0, 8)) - -+=== /types/src/foo.d.ts === -+export const foo: 1; -+>foo : Symbol(foo, Decl(foo.d.ts, 0, 12)) -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types index bc6fa3d56b..619e4bccd7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types @@ -7,9 +7,5 @@ export const foo = 1; === /test/foo.js === import { foo } from "js-self-name-import/foo.js"; ->foo : 1 - -=== /types/src/foo.d.ts === -export const foo: 1; ->foo : 1 +>foo : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff new file mode 100644 index 0000000000..6e5ad6de9a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff @@ -0,0 +1,48 @@ +--- old.nodeAllowJsPackageSelfName2.errors.txt ++++ new.nodeAllowJsPackageSelfName2.errors.txt +@@= skipped -0, +0 lines =@@ +- ++/test/foo.js(1,21): error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. ++ ++ ++==== /tsconfig.json (0 errors) ==== ++ { ++ "compilerOptions": { ++ "module": "nodenext", ++ "target": "esnext", ++ "emitDeclarationOnly": true, ++ "declaration": true, ++ "declarationDir": "./types", ++ "checkJs": true, ++ "rootDir": ".", ++ "strict": true, ++ }, ++ "include": ["src", "test"] ++ } ++ ++==== /src/foo.js (0 errors) ==== ++ export const foo = 1; ++ ++==== /test/foo.js (1 errors) ==== ++ import { foo } from "js-self-name-import/foo.js"; ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ++!!! error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. ++ ++==== /package.json (0 errors) ==== ++ { ++ "name": "js-self-name-import", ++ "type": "module", ++ "exports": { ++ "./*": { ++ "types": "./types/src/*", ++ "default": "./src/*" ++ } ++ } ++ } ++ ++==== /types/src/foo.d.ts (0 errors) ==== ++ export const foo: 1; ++ ++==== /types/test/foo.d.ts (0 errors) ==== ++ export {}; ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff index fc132a3084..87d1347809 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff @@ -1,10 +1,8 @@ --- old.nodeAllowJsPackageSelfName2.types +++ new.nodeAllowJsPackageSelfName2.types -@@= skipped -8, +8 lines =@@ - import { foo } from "js-self-name-import/foo.js"; - >foo : 1 +@@= skipped -6, +6 lines =@@ -+=== /types/src/foo.d.ts === -+export const foo: 1; -+>foo : 1 -+ \ No newline at end of file + === /test/foo.js === + import { foo } from "js-self-name-import/foo.js"; +->foo : 1 ++>foo : any From 76104bb58d628212621963ad766c767ee079953b Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 20:26:25 -0700 Subject: [PATCH 03/16] more --- internal/module/resolver.go | 2 +- .../nodeAllowJsPackageSelfName2.errors.txt | 44 ----------------- .../nodeAllowJsPackageSelfName2.types | 2 +- ...odeAllowJsPackageSelfName2.errors.txt.diff | 48 ------------------- .../nodeAllowJsPackageSelfName2.types.diff | 8 ---- 5 files changed, 2 insertions(+), 102 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff diff --git a/internal/module/resolver.go b/internal/module/resolver.go index da52af4777..04282cdb02 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -859,7 +859,7 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { if path, ok := r.tryFile(possibleInputWithInputExtension, false); ok { - extension := tspath.TryExtractTSExtension(path) + extension := tspath.TryGetExtensionFromPath(path) return &resolved{ path: path, extension: extension, diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt deleted file mode 100644 index 8298b0435a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -/test/foo.js(1,21): error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. - - -==== /tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "target": "esnext", - "emitDeclarationOnly": true, - "declaration": true, - "declarationDir": "./types", - "checkJs": true, - "rootDir": ".", - "strict": true, - }, - "include": ["src", "test"] - } - -==== /src/foo.js (0 errors) ==== - export const foo = 1; - -==== /test/foo.js (1 errors) ==== - import { foo } from "js-self-name-import/foo.js"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. - -==== /package.json (0 errors) ==== - { - "name": "js-self-name-import", - "type": "module", - "exports": { - "./*": { - "types": "./types/src/*", - "default": "./src/*" - } - } - } - -==== /types/src/foo.d.ts (0 errors) ==== - export const foo: 1; - -==== /types/test/foo.d.ts (0 errors) ==== - export {}; - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types index 619e4bccd7..b5d4bfc7cf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types @@ -7,5 +7,5 @@ export const foo = 1; === /test/foo.js === import { foo } from "js-self-name-import/foo.js"; ->foo : any +>foo : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff deleted file mode 100644 index 6e5ad6de9a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.errors.txt.diff +++ /dev/null @@ -1,48 +0,0 @@ ---- old.nodeAllowJsPackageSelfName2.errors.txt -+++ new.nodeAllowJsPackageSelfName2.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/test/foo.js(1,21): error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. -+ -+ -+==== /tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "target": "esnext", -+ "emitDeclarationOnly": true, -+ "declaration": true, -+ "declarationDir": "./types", -+ "checkJs": true, -+ "rootDir": ".", -+ "strict": true, -+ }, -+ "include": ["src", "test"] -+ } -+ -+==== /src/foo.js (0 errors) ==== -+ export const foo = 1; -+ -+==== /test/foo.js (1 errors) ==== -+ import { foo } from "js-self-name-import/foo.js"; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS6263: Module 'js-self-name-import/foo.js' was resolved to '/src/foo.js', but '--allowArbitraryExtensions' is not set. -+ -+==== /package.json (0 errors) ==== -+ { -+ "name": "js-self-name-import", -+ "type": "module", -+ "exports": { -+ "./*": { -+ "types": "./types/src/*", -+ "default": "./src/*" -+ } -+ } -+ } -+ -+==== /types/src/foo.d.ts (0 errors) ==== -+ export const foo: 1; -+ -+==== /types/test/foo.d.ts (0 errors) ==== -+ export {}; -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff deleted file mode 100644 index 87d1347809..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.nodeAllowJsPackageSelfName2.types -+++ new.nodeAllowJsPackageSelfName2.types -@@= skipped -6, +6 lines =@@ - - === /test/foo.js === - import { foo } from "js-self-name-import/foo.js"; -->foo : 1 -+>foo : any From 9b5ddfe1e74eb73373ec524b30b8cdcc3ab9306a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 20:33:47 -0700 Subject: [PATCH 04/16] correct fix maybe --- internal/module/resolver.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 04282cdb02..564bb0ba99 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -858,13 +858,9 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string } possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { - if path, ok := r.tryFile(possibleInputWithInputExtension, false); ok { - extension := tspath.TryGetExtensionFromPath(path) - return &resolved{ - path: path, - extension: extension, - resolvedUsingTsExtension: false, // These are input files, not output files accessed with TS extensions - } + resolved := r.loadFileNameFromPackageJSONField(r.extensions, possibleInputWithInputExtension, "", false) + if !resolved.shouldContinueSearching() { + return resolved } } } From 916c1ac5b60b97ae4fe52c615cdbd2c1d5da1d5c Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 21:11:06 -0700 Subject: [PATCH 05/16] Fix crash --- internal/module/resolver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 564bb0ba99..78aac77afc 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -1543,7 +1543,7 @@ func (r *resolutionState) loadFileNameFromPackageJSONField(extensions extensions return &resolved{ path: path, extension: extension, - resolvedUsingTsExtension: !strings.HasSuffix(packageJSONValue, extension), + resolvedUsingTsExtension: packageJSONValue != "" && !strings.HasSuffix(packageJSONValue, extension), } } return continueSearching() From 0cbc00eaf44360f07eb4e62c1b0335e18f572440 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 23:05:11 -0700 Subject: [PATCH 06/16] pointer --- internal/module/resolver.go | 4 ++-- internal/module/types.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 78aac77afc..e53ecb2ba7 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -55,7 +55,7 @@ type resolutionState struct { resolvedPackageDirectory bool failedLookupLocations []string affectingLocations []string - diagnostics []ast.Diagnostic + diagnostics []*ast.Diagnostic } func newResolutionState( @@ -835,7 +835,7 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string packagePath, ) } - r.diagnostics = append(r.diagnostics, *diagnostic) + r.diagnostics = append(r.diagnostics, diagnostic) } for _, commonSourceDirGuess := range commonSourceDirGuesses { diff --git a/internal/module/types.go b/internal/module/types.go index d0acc036da..f3c78cc715 100644 --- a/internal/module/types.go +++ b/internal/module/types.go @@ -63,7 +63,7 @@ func (p *PackageId) PackageName() string { type LookupLocations struct { FailedLookupLocations []string AffectingLocations []string - ResolutionDiagnostics []ast.Diagnostic + ResolutionDiagnostics []*ast.Diagnostic } type ResolvedModule struct { From fb51fbd3b5f722d91100b3cce1d01016b097c395 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:03:04 -0700 Subject: [PATCH 07/16] File loader diags --- internal/compiler/fileloader.go | 17 +++++++++++++++++ internal/compiler/parsetask.go | 1 + internal/compiler/program.go | 7 +++++++ internal/execute/tsc.go | 1 + internal/testutil/harnessutil/harnessutil.go | 1 + 5 files changed, 27 insertions(+) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 708307c455..0a9ca6bc03 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -54,6 +54,7 @@ type processedFiles struct { // List of present unsupported extensions unsupportedExtensions []string sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path] + fileLoadDiagnostics *ast.DiagnosticsCollection } type jsxRuntimeImportSpecifier struct { @@ -132,6 +133,7 @@ func processAllProgramFiles( var unsupportedExtensions []string var sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path] var libFileSet collections.Set[tspath.Path] + fileLoadDiagnostics := &ast.DiagnosticsCollection{} loader.parseTasks.collect(&loader, loader.rootTasks, func(task *parseTask, _ []tspath.Path) { if task.isRedirected { @@ -159,6 +161,18 @@ func processAllProgramFiles( resolvedModules[path] = task.resolutionsInFile typeResolutionsInFile[path] = task.typeResolutionsInFile sourceFileMetaDatas[path] = task.metadata + + // Collect resolution diagnostics from resolved modules and type reference directives + for _, resolvedModule := range task.resolutionsInFile { + for _, diag := range resolvedModule.ResolutionDiagnostics { + fileLoadDiagnostics.Add(&diag) + } + } + for _, resolvedTypeRef := range task.typeResolutionsInFile { + for _, diag := range resolvedTypeRef.ResolutionDiagnostics { + fileLoadDiagnostics.Add(&diag) + } + } if task.jsxRuntimeImportSpecifier != nil { if jsxRuntimeImportSpecifiers == nil { jsxRuntimeImportSpecifiers = make(map[tspath.Path]*jsxRuntimeImportSpecifier, totalFileCount) @@ -201,6 +215,7 @@ func processAllProgramFiles( unsupportedExtensions: unsupportedExtensions, sourceFilesFoundSearchingNodeModules: sourceFilesFoundSearchingNodeModules, libFiles: libFileSet, + fileLoadDiagnostics: fileLoadDiagnostics, } } @@ -372,6 +387,8 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) { resolutionMode := getModeForTypeReferenceDirectiveInFile(ref, file, meta, module.GetCompilerOptionsWithRedirect(p.opts.Config.CompilerOptions(), redirect)) resolved := p.resolver.ResolveTypeReferenceDirective(ref.FileName, file.FileName(), resolutionMode, redirect) typeResolutionsInFile[module.ModeAwareCacheKey{Name: ref.FileName, Mode: resolutionMode}] = resolved + + // Collect diagnostics from the resolved type reference directive if resolved.IsResolved() { t.addSubTask(resolvedRef{ fileName: resolved.ResolvedFileName, diff --git a/internal/compiler/parsetask.go b/internal/compiler/parsetask.go index ebb6fdcce3..b0e55d6c1b 100644 --- a/internal/compiler/parsetask.go +++ b/internal/compiler/parsetask.go @@ -22,6 +22,7 @@ type parseTask struct { metadata ast.SourceFileMetaData resolutionsInFile module.ModeAwareCache[*module.ResolvedModule] typeResolutionsInFile module.ModeAwareCache[*module.ResolvedTypeReferenceDirective] + resolutionDiagnostics []ast.Diagnostic importHelpersImportSpecifier *ast.Node jsxRuntimeImportSpecifier *jsxRuntimeImportSpecifier increaseDepth bool diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 7dbd620a6e..5293b482e1 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -330,6 +330,13 @@ func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast. return p.getDiagnosticsHelper(ctx, sourceFile, true /*ensureBound*/, true /*ensureChecked*/, p.getSuggestionDiagnosticsForFile) } +func (p *Program) GetFileLoadDiagnostics() []*ast.Diagnostic { + if p.fileLoadDiagnostics == nil { + return nil + } + return SortAndDeduplicateDiagnostics(p.fileLoadDiagnostics.GetDiagnostics()) +} + func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic { var globalDiagnostics []*ast.Diagnostic checkers, done := p.checkerPool.GetAllCheckers(ctx) diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index f680ff880a..0d97a13180 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -296,6 +296,7 @@ func emitFilesAndReportErrors(sys System, program *compiler.Program, reportDiagn configFileParsingDiagnosticsLength := len(allDiagnostics) allDiagnostics = append(allDiagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) + allDiagnostics = append(allDiagnostics, program.GetFileLoadDiagnostics()...) if len(allDiagnostics) == configFileParsingDiagnosticsLength { // Options diagnostics include global diagnostics (even though we collect them separately), diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 9c2c324ef7..7f64e5355d 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -575,6 +575,7 @@ func compileFilesWithHost( ctx := context.Background() program := createProgram(host, config) var diagnostics []*ast.Diagnostic + diagnostics = append(diagnostics, program.GetFileLoadDiagnostics()...) diagnostics = append(diagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetGlobalDiagnostics(ctx)...) From 9bb8923e2ec1c377b37a20e3f5a4c4ab56958ff1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:14:15 -0700 Subject: [PATCH 08/16] more --- internal/compiler/program.go | 6 ++---- internal/execute/tsc.go | 2 +- internal/testutil/harnessutil/harnessutil.go | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 5293b482e1..f1369c3c07 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -330,10 +330,8 @@ func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast. return p.getDiagnosticsHelper(ctx, sourceFile, true /*ensureBound*/, true /*ensureChecked*/, p.getSuggestionDiagnosticsForFile) } -func (p *Program) GetFileLoadDiagnostics() []*ast.Diagnostic { - if p.fileLoadDiagnostics == nil { - return nil - } +func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic { + // !!! return SortAndDeduplicateDiagnostics(p.fileLoadDiagnostics.GetDiagnostics()) } diff --git a/internal/execute/tsc.go b/internal/execute/tsc.go index 0d97a13180..c2fefa12bd 100644 --- a/internal/execute/tsc.go +++ b/internal/execute/tsc.go @@ -296,7 +296,7 @@ func emitFilesAndReportErrors(sys System, program *compiler.Program, reportDiagn configFileParsingDiagnosticsLength := len(allDiagnostics) allDiagnostics = append(allDiagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) - allDiagnostics = append(allDiagnostics, program.GetFileLoadDiagnostics()...) + allDiagnostics = append(allDiagnostics, program.GetProgramDiagnostics()...) if len(allDiagnostics) == configFileParsingDiagnosticsLength { // Options diagnostics include global diagnostics (even though we collect them separately), diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 7f64e5355d..043bfa27cb 100644 --- a/internal/testutil/harnessutil/harnessutil.go +++ b/internal/testutil/harnessutil/harnessutil.go @@ -575,7 +575,7 @@ func compileFilesWithHost( ctx := context.Background() program := createProgram(host, config) var diagnostics []*ast.Diagnostic - diagnostics = append(diagnostics, program.GetFileLoadDiagnostics()...) + diagnostics = append(diagnostics, program.GetProgramDiagnostics()...) diagnostics = append(diagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetGlobalDiagnostics(ctx)...) From 0247b42f455ced8b0ac73a7356b7e28dfde21bd7 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:15:14 -0700 Subject: [PATCH 09/16] remove outdated comment: --- internal/compiler/fileloader.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 0a9ca6bc03..3c5073d8f3 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -388,7 +388,6 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) { resolved := p.resolver.ResolveTypeReferenceDirective(ref.FileName, file.FileName(), resolutionMode, redirect) typeResolutionsInFile[module.ModeAwareCacheKey{Name: ref.FileName, Mode: resolutionMode}] = resolved - // Collect diagnostics from the resolved type reference directive if resolved.IsResolved() { t.addSubTask(resolvedRef{ fileName: resolved.ResolvedFileName, From 8be0f5ad407844a60c01c9e1415220890b646b42 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:49:47 -0700 Subject: [PATCH 10/16] refactor --- internal/compiler/fileloader.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 3c5073d8f3..963ccef45a 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -162,17 +162,6 @@ func processAllProgramFiles( typeResolutionsInFile[path] = task.typeResolutionsInFile sourceFileMetaDatas[path] = task.metadata - // Collect resolution diagnostics from resolved modules and type reference directives - for _, resolvedModule := range task.resolutionsInFile { - for _, diag := range resolvedModule.ResolutionDiagnostics { - fileLoadDiagnostics.Add(&diag) - } - } - for _, resolvedTypeRef := range task.typeResolutionsInFile { - for _, diag := range resolvedTypeRef.ResolutionDiagnostics { - fileLoadDiagnostics.Add(&diag) - } - } if task.jsxRuntimeImportSpecifier != nil { if jsxRuntimeImportSpecifiers == nil { jsxRuntimeImportSpecifiers = make(map[tspath.Path]*jsxRuntimeImportSpecifier, totalFileCount) @@ -197,8 +186,28 @@ func processAllProgramFiles( allFiles := append(libFiles, files...) + for _, resolutions := range resolvedModules { + for _, resolvedModule := range resolutions { + for _, diag := range resolvedModule.ResolutionDiagnostics { + fileLoadDiagnostics.Add(&diag) + } + } + } + for _, typeResolutions := range typeResolutionsInFile { + for _, resolvedTypeRef := range typeResolutions { + for _, diag := range resolvedTypeRef.ResolutionDiagnostics { + fileLoadDiagnostics.Add(&diag) + } + } + } + loader.pathForLibFileResolutions.Range(func(key tspath.Path, value module.ModeAwareCache[*module.ResolvedModule]) bool { resolvedModules[key] = value + for _, resolvedModule := range value { + for _, diag := range resolvedModule.ResolutionDiagnostics { + fileLoadDiagnostics.Add(&diag) + } + } return true }) From 3c514288d2edb286d3314196ab1920462790cbbf Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 26 Jun 2025 22:56:32 -0700 Subject: [PATCH 11/16] update --- internal/compiler/fileloader.go | 6 +++--- internal/compiler/parsetask.go | 2 +- internal/module/resolver.go | 2 +- internal/module/types.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 963ccef45a..431eb7b04a 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -189,14 +189,14 @@ func processAllProgramFiles( for _, resolutions := range resolvedModules { for _, resolvedModule := range resolutions { for _, diag := range resolvedModule.ResolutionDiagnostics { - fileLoadDiagnostics.Add(&diag) + fileLoadDiagnostics.Add(diag) } } } for _, typeResolutions := range typeResolutionsInFile { for _, resolvedTypeRef := range typeResolutions { for _, diag := range resolvedTypeRef.ResolutionDiagnostics { - fileLoadDiagnostics.Add(&diag) + fileLoadDiagnostics.Add(diag) } } } @@ -205,7 +205,7 @@ func processAllProgramFiles( resolvedModules[key] = value for _, resolvedModule := range value { for _, diag := range resolvedModule.ResolutionDiagnostics { - fileLoadDiagnostics.Add(&diag) + fileLoadDiagnostics.Add(diag) } } return true diff --git a/internal/compiler/parsetask.go b/internal/compiler/parsetask.go index b0e55d6c1b..9d7045bfc4 100644 --- a/internal/compiler/parsetask.go +++ b/internal/compiler/parsetask.go @@ -22,7 +22,7 @@ type parseTask struct { metadata ast.SourceFileMetaData resolutionsInFile module.ModeAwareCache[*module.ResolvedModule] typeResolutionsInFile module.ModeAwareCache[*module.ResolvedTypeReferenceDirective] - resolutionDiagnostics []ast.Diagnostic + resolutionDiagnostics []*ast.Diagnostic importHelpersImportSpecifier *ast.Node jsxRuntimeImportSpecifier *jsxRuntimeImportSpecifier increaseDepth bool diff --git a/internal/module/resolver.go b/internal/module/resolver.go index d054c1846d..7630b78eea 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -54,7 +54,7 @@ type resolutionState struct { resolvedPackageDirectory bool failedLookupLocations []string affectingLocations []string - diagnostics []ast.Diagnostic + diagnostics []*ast.Diagnostic } func newResolutionState( diff --git a/internal/module/types.go b/internal/module/types.go index d0acc036da..f3c78cc715 100644 --- a/internal/module/types.go +++ b/internal/module/types.go @@ -63,7 +63,7 @@ func (p *PackageId) PackageName() string { type LookupLocations struct { FailedLookupLocations []string AffectingLocations []string - ResolutionDiagnostics []ast.Diagnostic + ResolutionDiagnostics []*ast.Diagnostic } type ResolvedModule struct { From 2808146a354ff68d0c53c013980448c8c7a8e558 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 2 Jul 2025 07:52:12 -0700 Subject: [PATCH 12/16] Update baselines --- ...deNextPackageSelfNameWithOutDir.errors.txt | 19 +++ ...tPackageSelfNameWithOutDir.errors.txt.diff | 23 --- ...ackageSelfNameWithOutDirDeclDir.errors.txt | 22 +++ ...eSelfNameWithOutDirDeclDir.errors.txt.diff | 26 --- ...NameWithOutDirDeclDirNestedDirs.errors.txt | 41 +++++ ...ithOutDirDeclDirNestedDirs.errors.txt.diff | 45 ------ ...sPackageSelfName(module=node16).errors.txt | 2 + ...sPackageSelfName(module=node18).errors.txt | 2 + ...ackageSelfName(module=nodenext).errors.txt | 23 +++ ...alPackageExports(module=node16).errors.txt | 2 + ...alPackageExports(module=node18).errors.txt | 2 + ...PackageExports(module=nodenext).errors.txt | 126 +++++++++++++++ ...JsPackageExports(module=node16).errors.txt | 2 + ...JsPackageExports(module=node18).errors.txt | 2 + ...PackageExports(module=nodenext).errors.txt | 91 +++++++++++ ...JsPackageImports(module=node16).errors.txt | 2 + ...JsPackageImports(module=node18).errors.txt | 2 + ...PackageImports(module=nodenext).errors.txt | 40 +++++ ...alPackageExports(module=node16).errors.txt | 2 + ...kageExports(module=node16).errors.txt.diff | 15 +- ...alPackageExports(module=node18).errors.txt | 2 + ...kageExports(module=node18).errors.txt.diff | 15 +- ...PackageExports(module=nodenext).errors.txt | 126 +++++++++++++++ ...geExports(module=nodenext).errors.txt.diff | 149 +++--------------- ...thPackageExports(module=node16).errors.txt | 2 + ...kageExports(module=node16).errors.txt.diff | 15 -- ...thPackageExports(module=node18).errors.txt | 2 + ...kageExports(module=node18).errors.txt.diff | 15 -- ...PackageExports(module=nodenext).errors.txt | 2 + ...geExports(module=nodenext).errors.txt.diff | 13 -- ...esPackageExports(module=node16).errors.txt | 2 + ...kageExports(module=node16).errors.txt.diff | 10 +- ...esPackageExports(module=node18).errors.txt | 2 + ...kageExports(module=node18).errors.txt.diff | 10 +- ...PackageExports(module=nodenext).errors.txt | 91 +++++++++++ ...geExports(module=nodenext).errors.txt.diff | 105 ++---------- ...ageSelfName(module=node16).errors.txt.diff | 11 -- ...ageSelfName(module=node18).errors.txt.diff | 11 -- ...eSelfName(module=nodenext).errors.txt.diff | 27 ---- ...kageExports(module=node16).errors.txt.diff | 15 +- ...kageExports(module=node18).errors.txt.diff | 15 +- ...geExports(module=nodenext).errors.txt.diff | 149 +++--------------- ...kageExports(module=node16).errors.txt.diff | 10 +- ...kageExports(module=node18).errors.txt.diff | 10 +- ...geExports(module=nodenext).errors.txt.diff | 105 ++---------- ...kageImports(module=node16).errors.txt.diff | 12 -- ...kageImports(module=node18).errors.txt.diff | 12 -- ...geImports(module=nodenext).errors.txt.diff | 44 ------ 48 files changed, 713 insertions(+), 758 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt new file mode 100644 index 0000000000..331e173d70 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt @@ -0,0 +1,19 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== package.json (0 errors) ==== + { + "name": "@this/package", + "type": "module", + "exports": { + ".": "./dist/index.js" + } + } +==== index.ts (0 errors) ==== + import * as me from "@this/package"; + + me.thing(); + + export function thing(): void {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff deleted file mode 100644 index 35abf0463b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDir.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDir.errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== package.json (0 errors) ==== -- { -- "name": "@this/package", -- "type": "module", -- "exports": { -- ".": "./dist/index.js" -- } -- } --==== index.ts (0 errors) ==== -- import * as me from "@this/package"; -- -- me.thing(); -- -- export function thing(): void {} -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt new file mode 100644 index 0000000000..f9b1cfae73 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt @@ -0,0 +1,22 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== package.json (0 errors) ==== + { + "name": "@this/package", + "type": "module", + "exports": { + ".": { + "default": "./dist/index.js", + "types": "./types/index.d.ts" + } + } + } +==== index.ts (0 errors) ==== + import * as me from "@this/package"; + + me.thing(); + + export function thing(): void {} + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff deleted file mode 100644 index d46f6efd9d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== package.json (0 errors) ==== -- { -- "name": "@this/package", -- "type": "module", -- "exports": { -- ".": { -- "default": "./dist/index.js", -- "types": "./types/index.d.ts" -- } -- } -- } --==== index.ts (0 errors) ==== -- import * as me from "@this/package"; -- -- me.thing(); -- -- export function thing(): void {} -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt new file mode 100644 index 0000000000..500d58c848 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt @@ -0,0 +1,41 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "module": "nodenext", + "outDir": "./dist", + "declarationDir": "./types", + "declaration": true + } + } +==== index.ts (0 errors) ==== + export {srcthing as thing} from "./src/thing.js"; +==== src/thing.ts (0 errors) ==== + // The following import should cause `index.ts` + // to be included in the build, which will, + // in turn, cause the common src directory to not be `src` + // (the harness is wierd here in that noImplicitReferences makes only + // this file get loaded as an entrypoint and emitted, while on the + // real command-line we'll crawl the imports for that set - a limitation + // of the harness, I suppose) + import * as me from "@this/package"; + + me.thing(); + + export function srcthing(): void {} + + +==== package.json (0 errors) ==== + { + "name": "@this/package", + "type": "module", + "exports": { + ".": { + "default": "./dist/index.js", + "types": "./types/index.d.ts" + } + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff deleted file mode 100644 index ba75c52cb2..0000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff +++ /dev/null @@ -1,45 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== tsconfig.json (0 errors) ==== -- { -- "compilerOptions": { -- "module": "nodenext", -- "outDir": "./dist", -- "declarationDir": "./types", -- "declaration": true -- } -- } --==== index.ts (0 errors) ==== -- export {srcthing as thing} from "./src/thing.js"; --==== src/thing.ts (0 errors) ==== -- // The following import should cause `index.ts` -- // to be included in the build, which will, -- // in turn, cause the common src directory to not be `src` -- // (the harness is wierd here in that noImplicitReferences makes only -- // this file get loaded as an entrypoint and emitted, while on the -- // real command-line we'll crawl the imports for that set - a limitation -- // of the harness, I suppose) -- import * as me from "@this/package"; -- -- me.thing(); -- -- export function srcthing(): void {} -- -- --==== package.json (0 errors) ==== -- { -- "name": "@this/package", -- "type": "module", -- "exports": { -- ".": { -- "default": "./dist/index.js", -- "types": "./types/index.d.ts" -- } -- } -- } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt index 8192673cec..fe6d0aa7e4 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt @@ -1,6 +1,8 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as self from "package"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt index 8192673cec..fe6d0aa7e4 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt @@ -1,6 +1,8 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as self from "package"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt new file mode 100644 index 0000000000..8ceed405f3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt @@ -0,0 +1,23 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.js (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== index.mjs (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== index.cjs (0 errors) ==== + // esm format file + import * as self from "package"; + self; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt index 98529e67ed..177d7f86d0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@ -1,7 +1,9 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt index 98529e67ed..177d7f86d0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt @@ -1,7 +1,9 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt new file mode 100644 index 0000000000..850d0f056f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt @@ -0,0 +1,126 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.js (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== index.mjs (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== index.cjs (0 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.cjsSource; + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const implicitCjsSource = true; +==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const mjsSource = true; +==== node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const cjsSource = true; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts" + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt index a443d0e020..7433da8ed7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -5,6 +6,7 @@ node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a Common 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt index a443d0e020..7433da8ed7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -5,6 +6,7 @@ node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a Common 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt new file mode 100644 index 0000000000..42a27cf192 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt @@ -0,0 +1,91 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.js (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== index.mjs (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== index.cjs (0 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt index cda549c5c6..e845dc72f0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt @@ -1,7 +1,9 @@ +error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "#cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt index cda549c5c6..e845dc72f0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt @@ -1,7 +1,9 @@ +error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.js (0 errors) ==== // esm format file import * as cjs from "#cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt new file mode 100644 index 0000000000..ebcc53aeb3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt @@ -0,0 +1,40 @@ +error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.js (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== index.mjs (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== index.cjs (0 errors) ==== + // esm format file + import * as cjs from "#cjs"; + import * as mjs from "#mjs"; + import * as type from "#type"; + cjs; + mjs; + type; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js", + "imports": { + "#cjs": "./index.cjs", + "#mjs": "./index.mjs", + "#type": "./index.js" + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt index c68a2e33ac..440a46e1ec 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt @@ -1,7 +1,9 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff index e9942e7cee..7c61f43cb2 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff @@ -1,20 +1,15 @@ --- old.nodeModulesConditionalPackageExports(module=node16).errors.txt +++ new.nodeModulesConditionalPackageExports(module=node16).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+ -+ - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -57, +53 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -57, +55 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt index c68a2e33ac..440a46e1ec 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt @@ -1,7 +1,9 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff index 31501b0fc2..0411cc93c5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff @@ -1,20 +1,15 @@ --- old.nodeModulesConditionalPackageExports(module=node18).errors.txt +++ new.nodeModulesConditionalPackageExports(module=node18).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+ -+ - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -57, +53 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -57, +55 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt new file mode 100644 index 0000000000..b08caf68e1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt @@ -0,0 +1,126 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.ts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== index.mts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.mjsSource; + mjsi.mjsSource; + typei.mjsSource; + ts.mjsSource; +==== index.cts (0 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/a"; + import * as mjsi from "inner/b"; + import * as typei from "inner"; + import * as ts from "inner/types"; + cjsi.cjsSource; + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const implicitCjsSource = true; +==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const mjsSource = true; +==== node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; + export { cjs }; + export { mjs }; + export { type }; + export { ts }; + export const cjsSource = true; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./a": { + "require": "./index.cjs", + "node": "./index.mjs" + }, + "./b": { + "import": "./index.mjs", + "node": "./index.cjs" + }, + ".": { + "import": "./index.mjs", + "node": "./index.js" + }, + "./types": { + "types": { + "import": "./index.d.mts", + "require": "./index.d.cts" + }, + "node": { + "import": "./index.mjs", + "require": "./index.cjs" + } + } + } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff index 93dac80b72..0584fe2f8a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff @@ -1,136 +1,35 @@ --- old.nodeModulesConditionalPackageExports(module=nodenext).errors.txt +++ new.nodeModulesConditionalPackageExports(module=nodenext).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.ts (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.mjsSource; -- mjsi.mjsSource; -- typei.mjsSource; -- ts.mjsSource; --==== index.mts (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.mjsSource; -- mjsi.mjsSource; -- typei.mjsSource; -- ts.mjsSource; --==== index.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.cjsSource; -- mjsi.cjsSource; -- typei.implicitCjsSource; -- ts.cjsSource; + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -51, +49 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; -==== node_modules/inner/index.d.ts (1 errors) ==== -- // cjs format file -- import * as cjs from "inner/a"; ++==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const implicitCjsSource = true; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; +@@= skipped -13, +11 lines =@@ + export { type }; + export { ts }; + export const implicitCjsSource = true; -==== node_modules/inner/index.d.mts (1 errors) ==== -- // esm format file -- import * as cjs from "inner/a"; ++==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/a"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const mjsSource = true; --==== node_modules/inner/index.d.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "inner/a"; -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const cjsSource = true; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } --==== node_modules/inner/package.json (0 errors) ==== -- { -- "name": "inner", -- "private": true, -- "exports": { -- "./a": { -- "require": "./index.cjs", -- "node": "./index.mjs" -- }, -- "./b": { -- "import": "./index.mjs", -- "node": "./index.cjs" -- }, -- ".": { -- "import": "./index.mjs", -- "node": "./index.js" -- }, -- "./types": { -- "types": { -- "import": "./index.d.mts", -- "require": "./index.d.cts" -- }, -- "node": { -- "import": "./index.mjs", -- "require": "./index.cjs" -- } -- } -- } -- } -- -+ \ No newline at end of file + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt index f82891bb16..f2737ac29f 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -8,6 +9,7 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff deleted file mode 100644 index 4add3e1812..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt -+++ new.nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. - 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. -@@= skipped -8, +7 lines =@@ - node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. - - --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt index f82891bb16..f2737ac29f 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -8,6 +9,7 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff deleted file mode 100644 index fe5127f4e7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt -+++ new.nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. - 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. -@@= skipped -8, +7 lines =@@ - node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. - - --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt index ee951d981a..ed1769f353 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt @@ -1,8 +1,10 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff deleted file mode 100644 index aacb51049e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt -+++ new.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. - node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. - node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. - - --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt index ce2e504ca9..06b2bc6d3e 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -5,6 +6,7 @@ node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a Common 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff index e5ce7ee5df..fc6ff436f0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff @@ -1,8 +1,6 @@ --- old.nodeModulesPackageExports(module=node16).errors.txt +++ new.nodeModulesPackageExports(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. +@@= skipped -2, +2 lines =@@ 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. 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. 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. @@ -10,11 +8,7 @@ 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -55, +52 lines =@@ +@@= skipped -53, +52 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt index ce2e504ca9..06b2bc6d3e 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt @@ -1,3 +1,4 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. 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. @@ -5,6 +6,7 @@ node_modules/inner/index.d.cts(3,22): error TS1479: The current file is a Common 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== index.ts (0 errors) ==== // esm format file import * as cjs from "package/cjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff index 549e862520..1f1f2c7f11 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff @@ -1,8 +1,6 @@ --- old.nodeModulesPackageExports(module=node18).errors.txt +++ new.nodeModulesPackageExports(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. +@@= skipped -2, +2 lines =@@ 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. 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. 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. @@ -10,11 +8,7 @@ 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.ts (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -55, +52 lines =@@ +@@= skipped -53, +52 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt new file mode 100644 index 0000000000..64026b31c7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt @@ -0,0 +1,91 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== index.ts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== index.mts (0 errors) ==== + // esm format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== index.cts (0 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; + import * as mjs from "package/mjs"; + import * as type from "package"; + cjs; + mjs; + type; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; + cjsi; + mjsi; + typei; +==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== node_modules/inner/index.d.cts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; + export { mjs }; + export { type }; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } +==== node_modules/inner/package.json (0 errors) ==== + { + "name": "inner", + "private": true, + "exports": { + "./cjs": "./index.cjs", + "./mjs": "./index.mjs", + ".": "./index.js" + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff index 8664f03d23..b42f74a3e3 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff @@ -1,98 +1,21 @@ --- old.nodeModulesPackageExports(module=nodenext).errors.txt +++ new.nodeModulesPackageExports(module=nodenext).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.ts (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; --==== index.mts (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; --==== index.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -44, +43 lines =@@ + cjsi; + mjsi; + typei; -==== node_modules/inner/index.d.ts (1 errors) ==== -- // cjs format file -- import * as cjs from "inner/cjs"; ++==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== node_modules/inner/index.d.mts (0 errors) ==== -- // esm format file -- import * as cjs from "inner/cjs"; -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== node_modules/inner/index.d.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "inner/cjs"; -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } --==== node_modules/inner/package.json (0 errors) ==== -- { -- "name": "inner", -- "private": true, -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } -+ \ No newline at end of file + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff deleted file mode 100644 index dad6391b99..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.nodeAllowJsPackageSelfName(module=node16).errors.txt -+++ new.nodeAllowJsPackageSelfName(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as self from "package"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff deleted file mode 100644 index 4c45ede330..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.nodeAllowJsPackageSelfName(module=node18).errors.txt -+++ new.nodeAllowJsPackageSelfName(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as self from "package"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff deleted file mode 100644 index ed0557e4a3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.nodeAllowJsPackageSelfName(module=nodenext).errors.txt -+++ new.nodeAllowJsPackageSelfName(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.js (0 errors) ==== -- // esm format file -- import * as self from "package"; -- self; --==== index.mjs (0 errors) ==== -- // esm format file -- import * as self from "package"; -- self; --==== index.cjs (0 errors) ==== -- // esm format file -- import * as self from "package"; -- self; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": "./index.js" -- } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff index 58b08fb0e3..fa6d7597dc 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff @@ -1,20 +1,15 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt +++ new.nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+ -+ - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -57, +53 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -57, +55 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff index 2de1a10500..7cb6fd0a76 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff @@ -1,20 +1,15 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt +++ new.nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. 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. 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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+ -+ - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -57, +53 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -57, +55 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff index 0205855c12..b369a06955 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff @@ -1,136 +1,35 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt +++ new.nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.js (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.mjsSource; -- mjsi.mjsSource; -- typei.mjsSource; -- ts.mjsSource; --==== index.mjs (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.mjsSource; -- mjsi.mjsSource; -- typei.mjsSource; -- ts.mjsSource; --==== index.cjs (0 errors) ==== -- // cjs format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/a"; -- import * as mjsi from "inner/b"; -- import * as typei from "inner"; -- import * as ts from "inner/types"; -- cjsi.cjsSource; -- mjsi.cjsSource; -- typei.implicitCjsSource; -- ts.cjsSource; + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -51, +49 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; -==== node_modules/inner/index.d.ts (1 errors) ==== -- // cjs format file -- import * as cjs from "inner/a"; ++==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/a"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const implicitCjsSource = true; + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; +@@= skipped -13, +11 lines =@@ + export { type }; + export { ts }; + export const implicitCjsSource = true; -==== node_modules/inner/index.d.mts (1 errors) ==== -- // esm format file -- import * as cjs from "inner/a"; ++==== node_modules/inner/index.d.mts (0 errors) ==== + // esm format file + import * as cjs from "inner/a"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const mjsSource = true; --==== node_modules/inner/index.d.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "inner/a"; -- import * as mjs from "inner/b"; -- import * as type from "inner"; -- import * as ts from "inner/types"; -- export { cjs }; -- export { mjs }; -- export { type }; -- export { ts }; -- export const cjsSource = true; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } --==== node_modules/inner/package.json (0 errors) ==== -- { -- "name": "inner", -- "private": true, -- "exports": { -- "./a": { -- "require": "./index.cjs", -- "node": "./index.mjs" -- }, -- "./b": { -- "import": "./index.mjs", -- "node": "./index.cjs" -- }, -- ".": { -- "import": "./index.mjs", -- "node": "./index.js" -- }, -- "./types": { -- "types": { -- "import": "./index.d.mts", -- "require": "./index.d.cts" -- }, -- "node": { -- "import": "./index.mjs", -- "require": "./index.cjs" -- } -- } -- } -- } -- -+ \ No newline at end of file + import * as mjs from "inner/b"; + import * as type from "inner"; + import * as ts from "inner/types"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff index 53583e22aa..c5a0e95651 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff @@ -1,8 +1,6 @@ --- old.nodeModulesAllowJsPackageExports(module=node16).errors.txt +++ new.nodeModulesAllowJsPackageExports(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. +@@= skipped -2, +2 lines =@@ 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. 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. 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. @@ -10,11 +8,7 @@ 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -55, +52 lines =@@ +@@= skipped -53, +52 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff index d606aad7ef..805312f63f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff @@ -1,8 +1,6 @@ --- old.nodeModulesAllowJsPackageExports(module=node18).errors.txt +++ new.nodeModulesAllowJsPackageExports(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. +@@= skipped -2, +2 lines =@@ 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. 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. 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. @@ -10,11 +8,7 @@ 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "package/cjs"; -@@= skipped -55, +52 lines =@@ +@@= skipped -53, +52 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff index 440a91b5c4..27d47037fe 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff @@ -1,98 +1,21 @@ --- old.nodeModulesAllowJsPackageExports(module=nodenext).errors.txt +++ new.nodeModulesAllowJsPackageExports(module=nodenext).errors.txt @@= skipped -0, +0 lines =@@ --error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. -- -- --!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.js (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; --==== index.mjs (0 errors) ==== -- // esm format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; --==== index.cjs (0 errors) ==== -- // cjs format file -- import * as cjs from "package/cjs"; -- import * as mjs from "package/mjs"; -- import * as type from "package"; -- cjs; -- mjs; -- type; -- import * as cjsi from "inner/cjs"; -- import * as mjsi from "inner/mjs"; -- import * as typei from "inner"; -- cjsi; -- mjsi; -- typei; + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -44, +43 lines =@@ + cjsi; + mjsi; + typei; -==== node_modules/inner/index.d.ts (1 errors) ==== -- // cjs format file -- import * as cjs from "inner/cjs"; ++==== node_modules/inner/index.d.ts (0 errors) ==== + // cjs format file + import * as cjs from "inner/cjs"; - ~~~ -!!! error TS2303: Circular definition of import alias 'cjs'. -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== node_modules/inner/index.d.mts (0 errors) ==== -- // esm format file -- import * as cjs from "inner/cjs"; -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== node_modules/inner/index.d.cts (0 errors) ==== -- // cjs format file -- import * as cjs from "inner/cjs"; -- import * as mjs from "inner/mjs"; -- import * as type from "inner"; -- export { cjs }; -- export { mjs }; -- export { type }; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } --==== node_modules/inner/package.json (0 errors) ==== -- { -- "name": "inner", -- "private": true, -- "exports": { -- "./cjs": "./index.cjs", -- "./mjs": "./index.mjs", -- ".": "./index.js" -- } -- } -+ \ No newline at end of file + import * as mjs from "inner/mjs"; + import * as type from "inner"; + export { cjs }; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff deleted file mode 100644 index 1d2cbe9b35..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeModulesAllowJsPackageImports(module=node16).errors.txt -+++ new.nodeModulesAllowJsPackageImports(module=node16).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "#cjs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff deleted file mode 100644 index 110b3d4008..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeModulesAllowJsPackageImports(module=node18).errors.txt -+++ new.nodeModulesAllowJsPackageImports(module=node18).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. - ==== index.js (0 errors) ==== - // esm format file - import * as cjs from "#cjs"; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff deleted file mode 100644 index 493bdc69ed..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.nodeModulesAllowJsPackageImports(module=nodenext).errors.txt -+++ new.nodeModulesAllowJsPackageImports(module=nodenext).errors.txt -@@= skipped -0, +0 lines =@@ --error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -- -- --!!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. --==== index.js (0 errors) ==== -- // esm format file -- import * as cjs from "#cjs"; -- import * as mjs from "#mjs"; -- import * as type from "#type"; -- cjs; -- mjs; -- type; --==== index.mjs (0 errors) ==== -- // esm format file -- import * as cjs from "#cjs"; -- import * as mjs from "#mjs"; -- import * as type from "#type"; -- cjs; -- mjs; -- type; --==== index.cjs (0 errors) ==== -- // esm format file -- import * as cjs from "#cjs"; -- import * as mjs from "#mjs"; -- import * as type from "#type"; -- cjs; -- mjs; -- type; --==== package.json (0 errors) ==== -- { -- "name": "package", -- "private": true, -- "type": "module", -- "exports": "./index.js", -- "imports": { -- "#cjs": "./index.cjs", -- "#mjs": "./index.mjs", -- "#type": "./index.js" -- } -- } -+ \ No newline at end of file From 051dcbdd637297d0226938472ce251c80ba938e0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 2 Jul 2025 13:50:24 -0700 Subject: [PATCH 13/16] Add test from issue --- .../reference/compiler/subpathImportsJS.js | 30 +++++++++++++++++++ .../compiler/subpathImportsJS.symbols | 13 ++++++++ .../reference/compiler/subpathImportsJS.types | 14 +++++++++ .../tests/cases/compiler/subpathImportsJS.ts | 26 ++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 testdata/baselines/reference/compiler/subpathImportsJS.js create mode 100644 testdata/baselines/reference/compiler/subpathImportsJS.symbols create mode 100644 testdata/baselines/reference/compiler/subpathImportsJS.types create mode 100644 testdata/tests/cases/compiler/subpathImportsJS.ts diff --git a/testdata/baselines/reference/compiler/subpathImportsJS.js b/testdata/baselines/reference/compiler/subpathImportsJS.js new file mode 100644 index 0000000000..8fb7c1666f --- /dev/null +++ b/testdata/baselines/reference/compiler/subpathImportsJS.js @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/subpathImportsJS.ts] //// + +//// [package.json] +{ + "name": "pkg", + "type": "module", + "imports": { + "#subpath": "./dist/subpath.js" + } +} + +//// [subpath.ts] +export const foo = "foo"; + +//// [index.ts] +import { foo } from "#subpath"; +foo; + + +//// [subpath.js] +export const foo = "foo"; +//// [index.js] +import { foo } from "#subpath"; +foo; + + +//// [subpath.d.ts] +export declare const foo = "foo"; +//// [index.d.ts] +export {}; diff --git a/testdata/baselines/reference/compiler/subpathImportsJS.symbols b/testdata/baselines/reference/compiler/subpathImportsJS.symbols new file mode 100644 index 0000000000..93f0870b6c --- /dev/null +++ b/testdata/baselines/reference/compiler/subpathImportsJS.symbols @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/subpathImportsJS.ts] //// + +=== /src/subpath.ts === +export const foo = "foo"; +>foo : Symbol(foo, Decl(subpath.ts, 0, 12)) + +=== /src/index.ts === +import { foo } from "#subpath"; +>foo : Symbol(foo, Decl(index.ts, 0, 8)) + +foo; +>foo : Symbol(foo, Decl(index.ts, 0, 8)) + diff --git a/testdata/baselines/reference/compiler/subpathImportsJS.types b/testdata/baselines/reference/compiler/subpathImportsJS.types new file mode 100644 index 0000000000..5bf435248e --- /dev/null +++ b/testdata/baselines/reference/compiler/subpathImportsJS.types @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/subpathImportsJS.ts] //// + +=== /src/subpath.ts === +export const foo = "foo"; +>foo : "foo" +>"foo" : "foo" + +=== /src/index.ts === +import { foo } from "#subpath"; +>foo : "foo" + +foo; +>foo : "foo" + diff --git a/testdata/tests/cases/compiler/subpathImportsJS.ts b/testdata/tests/cases/compiler/subpathImportsJS.ts new file mode 100644 index 0000000000..b00ed77066 --- /dev/null +++ b/testdata/tests/cases/compiler/subpathImportsJS.ts @@ -0,0 +1,26 @@ +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "module": "nodenext", + "outDir": "dist", + "rootDir": "src", + "declaration": true, + }, + "include": ["src/*.ts"] +} + +// @Filename: /package.json +{ + "name": "pkg", + "type": "module", + "imports": { + "#subpath": "./dist/subpath.js" + } +} + +// @Filename: /src/subpath.ts +export const foo = "foo"; + +// @Filename: /src/index.ts +import { foo } from "#subpath"; +foo; From b937bb65f8edc8c585c1ceb6bd22f7436a4d4b45 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:11:13 -0700 Subject: [PATCH 14/16] Remove the guessing code, skip more module tests --- internal/module/resolver.go | 136 +++++------------- internal/module/resolver_test.go | 6 + ...deNextPackageSelfNameWithOutDir.errors.txt | 5 +- ...tPackageSelfNameWithOutDir.errors.txt.diff | 20 +++ .../nodeNextPackageSelfNameWithOutDir.symbols | 2 - ...NextPackageSelfNameWithOutDir.symbols.diff | 12 ++ .../nodeNextPackageSelfNameWithOutDir.types | 10 +- ...deNextPackageSelfNameWithOutDir.types.diff | 21 +++ ...ackageSelfNameWithOutDirDeclDir.errors.txt | 5 +- ...eSelfNameWithOutDirDeclDir.errors.txt.diff | 20 +++ ...xtPackageSelfNameWithOutDirDeclDir.symbols | 2 - ...kageSelfNameWithOutDirDeclDir.symbols.diff | 12 ++ ...NextPackageSelfNameWithOutDirDeclDir.types | 10 +- ...ackageSelfNameWithOutDirDeclDir.types.diff | 21 +++ ...fNameWithOutDirDeclDirComposite.errors.txt | 34 +++++ ...WithOutDirDeclDirComposite.errors.txt.diff | 38 +++++ ...SelfNameWithOutDirDeclDirComposite.symbols | 2 - ...ameWithOutDirDeclDirComposite.symbols.diff | 12 ++ ...geSelfNameWithOutDirDeclDirComposite.types | 10 +- ...fNameWithOutDirDeclDirComposite.types.diff | 21 +++ ...utDirDeclDirCompositeNestedDirs.errors.txt | 44 ++++++ ...DeclDirCompositeNestedDirs.errors.txt.diff | 48 +++++++ ...thOutDirDeclDirCompositeNestedDirs.symbols | 2 - ...DirDeclDirCompositeNestedDirs.symbols.diff | 2 - ...WithOutDirDeclDirCompositeNestedDirs.types | 10 +- ...utDirDeclDirCompositeNestedDirs.types.diff | 21 +++ ...NameWithOutDirDeclDirNestedDirs.errors.txt | 5 +- ...ithOutDirDeclDirNestedDirs.errors.txt.diff | 26 ++++ ...elfNameWithOutDirDeclDirNestedDirs.symbols | 2 - ...meWithOutDirDeclDirNestedDirs.symbols.diff | 2 - ...eSelfNameWithOutDirDeclDirNestedDirs.types | 10 +- ...NameWithOutDirDeclDirNestedDirs.types.diff | 21 +++ ...sPackageSelfName(module=node16).errors.txt | 14 +- ...llowJsPackageSelfName(module=node16).types | 12 +- ...sPackageSelfName(module=node18).errors.txt | 14 +- ...llowJsPackageSelfName(module=node18).types | 12 +- ...ackageSelfName(module=nodenext).errors.txt | 15 +- ...owJsPackageSelfName(module=nodenext).types | 12 +- ...alPackageExports(module=node16).errors.txt | 35 ++++- ...onditionalPackageExports(module=node16).js | 36 ++--- ...ionalPackageExports(module=node16).js.diff | 57 ++++++++ ...itionalPackageExports(module=node16).types | 36 ++--- ...alPackageExports(module=node18).errors.txt | 35 ++++- ...onditionalPackageExports(module=node18).js | 36 ++--- ...ionalPackageExports(module=node18).js.diff | 56 +++++++- ...itionalPackageExports(module=node18).types | 36 ++--- ...PackageExports(module=nodenext).errors.txt | 33 ++++- ...ditionalPackageExports(module=nodenext).js | 36 ++--- ...nalPackageExports(module=nodenext).js.diff | 57 ++++++++ ...ionalPackageExports(module=nodenext).types | 36 ++--- ...JsPackageExports(module=node16).errors.txt | 35 ++++- ...lesAllowJsPackageExports(module=node16).js | 32 ++--- ...lowJsPackageExports(module=node16).js.diff | 53 +++++++ ...AllowJsPackageExports(module=node16).types | 36 ++--- ...JsPackageExports(module=node18).errors.txt | 35 ++++- ...lesAllowJsPackageExports(module=node18).js | 32 ++--- ...lowJsPackageExports(module=node18).js.diff | 73 ++++++++-- ...AllowJsPackageExports(module=node18).types | 36 ++--- ...PackageExports(module=nodenext).errors.txt | 33 ++++- ...sAllowJsPackageExports(module=nodenext).js | 32 ++--- ...wJsPackageExports(module=nodenext).js.diff | 53 +++++++ ...lowJsPackageExports(module=nodenext).types | 36 ++--- ...JsPackageImports(module=node16).errors.txt | 35 ++++- ...lesAllowJsPackageImports(module=node16).js | 20 +-- ...lowJsPackageImports(module=node16).js.diff | 41 ++++++ ...AllowJsPackageImports(module=node16).types | 36 ++--- ...JsPackageImports(module=node18).errors.txt | 35 ++++- ...lesAllowJsPackageImports(module=node18).js | 20 +-- ...lowJsPackageImports(module=node18).js.diff | 46 +++++- ...AllowJsPackageImports(module=node18).types | 36 ++--- ...PackageImports(module=nodenext).errors.txt | 33 ++++- ...sAllowJsPackageImports(module=nodenext).js | 20 +-- ...wJsPackageImports(module=nodenext).js.diff | 41 ++++++ ...lowJsPackageImports(module=nodenext).types | 36 ++--- ...alPackageExports(module=node16).errors.txt | 35 ++++- ...kageExports(module=node16).errors.txt.diff | 108 +++++++++++++- ...onditionalPackageExports(module=node16).js | 36 ++--- ...ionalPackageExports(module=node16).js.diff | 57 ++++++++ ...itionalPackageExports(module=node16).types | 36 ++--- ...alPackageExports(module=node16).types.diff | 89 +++++++++++- ...alPackageExports(module=node18).errors.txt | 35 ++++- ...kageExports(module=node18).errors.txt.diff | 108 +++++++++++++- ...onditionalPackageExports(module=node18).js | 36 ++--- ...ionalPackageExports(module=node18).js.diff | 56 +++++++- ...itionalPackageExports(module=node18).types | 36 ++--- ...alPackageExports(module=node18).types.diff | 89 +++++++++++- ...PackageExports(module=nodenext).errors.txt | 33 ++++- ...geExports(module=nodenext).errors.txt.diff | 102 ++++++++++++- ...ditionalPackageExports(module=nodenext).js | 36 ++--- ...nalPackageExports(module=nodenext).js.diff | 57 ++++++++ ...ionalPackageExports(module=nodenext).types | 36 ++--- ...PackageExports(module=nodenext).types.diff | 89 +++++++++++- ...thPackageExports(module=node16).errors.txt | 35 ++++- ...kageExports(module=node16).errors.txt.diff | 108 ++++++++++++++ ...onEmitWithPackageExports(module=node16).js | 64 ++++----- ...tWithPackageExports(module=node16).js.diff | 104 +++++++++++--- ...mitWithPackageExports(module=node16).types | 54 +++---- ...thPackageExports(module=node16).types.diff | 107 ++++++++++++++ ...thPackageExports(module=node18).errors.txt | 35 ++++- ...kageExports(module=node18).errors.txt.diff | 108 ++++++++++++++ ...onEmitWithPackageExports(module=node18).js | 64 ++++----- ...tWithPackageExports(module=node18).js.diff | 106 +++++++++++--- ...mitWithPackageExports(module=node18).types | 54 +++---- ...thPackageExports(module=node18).types.diff | 107 ++++++++++++++ ...PackageExports(module=nodenext).errors.txt | 33 ++++- ...geExports(module=nodenext).errors.txt.diff | 102 +++++++++++++ ...EmitWithPackageExports(module=nodenext).js | 64 ++++----- ...ithPackageExports(module=nodenext).js.diff | 104 +++++++++++--- ...tWithPackageExports(module=nodenext).types | 54 +++---- ...PackageExports(module=nodenext).types.diff | 107 ++++++++++++++ ...esPackageExports(module=node16).errors.txt | 35 ++++- ...kageExports(module=node16).errors.txt.diff | 103 ++++++++++++- ...odeModulesPackageExports(module=node16).js | 32 ++--- ...dulesPackageExports(module=node16).js.diff | 53 +++++++ ...ModulesPackageExports(module=node16).types | 36 ++--- ...esPackageExports(module=node16).types.diff | 93 +++++++++++- ...esPackageExports(module=node18).errors.txt | 35 ++++- ...kageExports(module=node18).errors.txt.diff | 103 ++++++++++++- ...odeModulesPackageExports(module=node18).js | 32 ++--- ...dulesPackageExports(module=node18).js.diff | 73 ++++++++-- ...ModulesPackageExports(module=node18).types | 36 ++--- ...esPackageExports(module=node18).types.diff | 93 +++++++++++- ...PackageExports(module=nodenext).errors.txt | 33 ++++- ...geExports(module=nodenext).errors.txt.diff | 94 +++++++++++- ...eModulesPackageExports(module=nodenext).js | 32 ++--- ...lesPackageExports(module=nodenext).js.diff | 53 +++++++ ...dulesPackageExports(module=nodenext).types | 36 ++--- ...PackageExports(module=nodenext).types.diff | 93 +++++++++++- ...ageSelfName(module=node16).errors.txt.diff | 34 +++++ ...sPackageSelfName(module=node16).types.diff | 32 +++++ ...ageSelfName(module=node18).errors.txt.diff | 34 +++++ ...sPackageSelfName(module=node18).types.diff | 32 +++++ ...eSelfName(module=nodenext).errors.txt.diff | 41 ++++++ ...ackageSelfName(module=nodenext).types.diff | 32 +++++ ...kageExports(module=node16).errors.txt.diff | 108 +++++++++++++- ...alPackageExports(module=node16).types.diff | 89 +++++++++++- ...kageExports(module=node18).errors.txt.diff | 108 +++++++++++++- ...alPackageExports(module=node18).types.diff | 89 +++++++++++- ...geExports(module=nodenext).errors.txt.diff | 102 ++++++++++++- ...PackageExports(module=nodenext).types.diff | 89 +++++++++++- ...kageExports(module=node16).errors.txt.diff | 103 ++++++++++++- ...JsPackageExports(module=node16).types.diff | 93 +++++++++++- ...kageExports(module=node18).errors.txt.diff | 103 ++++++++++++- ...JsPackageExports(module=node18).types.diff | 93 +++++++++++- ...geExports(module=nodenext).errors.txt.diff | 94 +++++++++++- ...PackageExports(module=nodenext).types.diff | 93 +++++++++++- ...kageImports(module=node16).errors.txt.diff | 85 +++++++++++ ...JsPackageImports(module=node16).types.diff | 80 +++++++++++ ...kageImports(module=node18).errors.txt.diff | 85 +++++++++++ ...JsPackageImports(module=node18).types.diff | 80 +++++++++++ ...geImports(module=nodenext).errors.txt.diff | 79 ++++++++++ ...PackageImports(module=nodenext).types.diff | 80 +++++++++++ 152 files changed, 6327 insertions(+), 1125 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js.diff create mode 100644 testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types.diff diff --git a/internal/module/resolver.go b/internal/module/resolver.go index e53ecb2ba7..8d92047326 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -9,7 +9,6 @@ import ( "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/outputpaths" "github.com/microsoft/typescript-go/internal/packagejson" "github.com/microsoft/typescript-go/internal/semver" "github.com/microsoft/typescript-go/internal/tspath" @@ -35,6 +34,10 @@ func continueSearching() *resolved { return nil } +func unresolved() *resolved { + return &resolved{} +} + type resolutionKindSpecificLoader = func(extensions extensions, candidate string, onlyRecordFailures bool) *resolved type resolutionState struct { @@ -750,10 +753,6 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string, packagePath string, isImports bool) *resolved { // Replace any references to outputs for files in the program with the input files to support package self-names used with outDir - // PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure - // we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving! - // _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!). - // We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups. if !r.isConfigLookup && (r.compilerOptions.DeclarationDir != "" || r.compilerOptions.OutDir != "") && !strings.Contains(finalPath, "/node_modules/") && @@ -765,58 +764,18 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string CurrentDirectory: r.resolver.host.GetCurrentDirectory(), }, )) { - // So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings. - // Even with all that, we still don't know if the root of the output file structure will be (relative to the package file) - // `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.) - - useCaseSensitiveFileNames := r.resolver.host.FS().UseCaseSensitiveFileNames() - var commonSourceDirGuesses []string - - // A `rootDir` compiler option strongly indicates the root location - // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations - if r.compilerOptions.RootDir != "" || (r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "") { - commonDir := tspath.GetNormalizedAbsolutePath(r.getCommonSourceDirectory(), r.resolver.host.GetCurrentDirectory()) - commonSourceDirGuesses = append(commonSourceDirGuesses, commonDir) - } else if r.containingDirectory != "" { - // However without either of those set we're in the dark. Let's say you have - // - // ./tools/index.ts - // ./src/index.ts - // ./dist/index.js - // ./package.json <-- references ./dist/index.js - // ./tsconfig.json <-- loads ./src/index.ts - // - // How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename? - // Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from - // without more context. - // But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too - // must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.containingDirectory - - requestingFile := tspath.GetNormalizedAbsolutePath(tspath.CombinePaths(r.containingDirectory, "index.ts"), r.resolver.host.GetCurrentDirectory()) - // And we can try every folder above the common folder for the request folder and the config/package base directory - // This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't - // know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything - // else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then - // be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup - // logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all - // internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first. - commonDir := tspath.GetNormalizedAbsolutePath(r.getCommonSourceDirectoryForFiles([]string{requestingFile, tspath.GetNormalizedAbsolutePath(packagePath, r.resolver.host.GetCurrentDirectory())}), r.resolver.host.GetCurrentDirectory()) - commonSourceDirGuesses = append(commonSourceDirGuesses, commonDir) - - fragment := tspath.EnsureTrailingDirectorySeparator(commonDir) - for len(fragment) > 1 { - parts := tspath.GetPathComponents(fragment, "") - if len(parts) <= 1 { - break - } - parts = parts[:len(parts)-1] // remove a directory - commonDir := tspath.GetPathFromPathComponents(parts) - commonSourceDirGuesses = append([]string{commonDir}, commonSourceDirGuesses...) // unshift - fragment = tspath.EnsureTrailingDirectorySeparator(commonDir) - } - } - if len(commonSourceDirGuesses) > 1 { + // Note: this differs from Strada's tryLoadInputFileForPath in that it + // does not attempt to perform "guesses", instead requring a clear root indicator. + + var rootDir string + if r.compilerOptions.RootDir != "" { + // A `rootDir` compiler option strongly indicates the root location + rootDir = r.compilerOptions.RootDir + } else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath == "" { + // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations + rootDir = r.compilerOptions.ConfigFilePath + } else { var diagnostic *ast.Diagnostic if isImports { diagnostic = ast.NewDiagnostic( @@ -836,32 +795,31 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string ) } r.diagnostics = append(r.diagnostics, diagnostic) + return unresolved() } - for _, commonSourceDirGuess := range commonSourceDirGuesses { - candidateDirectories := r.getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) - for _, candidateDir := range candidateDirectories { - if tspath.ContainsPath(candidateDir, finalPath, tspath.ComparePathsOptions{ - UseCaseSensitiveFileNames: useCaseSensitiveFileNames, - CurrentDirectory: r.resolver.host.GetCurrentDirectory(), - }) { - // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension - pathFragment := finalPath[len(candidateDir)+1:] // +1 to also remove directory separator - possibleInputBase := tspath.CombinePaths(commonSourceDirGuess, pathFragment) - jsAndDtsExtensions := []string{tspath.ExtensionMjs, tspath.ExtensionCjs, tspath.ExtensionJs, tspath.ExtensionJson, tspath.ExtensionDmts, tspath.ExtensionDcts, tspath.ExtensionDts} - for _, ext := range jsAndDtsExtensions { - if tspath.FileExtensionIs(possibleInputBase, ext) { - inputExts := r.getPossibleOriginalInputExtensionForExtension(possibleInputBase) - for _, possibleExt := range inputExts { - if !extensionIsOk(r.extensions, possibleExt) { - continue - } - possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) - if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { - resolved := r.loadFileNameFromPackageJSONField(r.extensions, possibleInputWithInputExtension, "", false) - if !resolved.shouldContinueSearching() { - return resolved - } + candidateDirectories := r.getOutputDirectoriesForBaseDirectory(rootDir) + for _, candidateDir := range candidateDirectories { + if tspath.ContainsPath(candidateDir, finalPath, tspath.ComparePathsOptions{ + UseCaseSensitiveFileNames: r.resolver.host.FS().UseCaseSensitiveFileNames(), + CurrentDirectory: r.resolver.host.GetCurrentDirectory(), + }) { + // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension + pathFragment := finalPath[len(candidateDir)+1:] // +1 to also remove directory separator + possibleInputBase := tspath.CombinePaths(rootDir, pathFragment) + jsAndDtsExtensions := []string{tspath.ExtensionMjs, tspath.ExtensionCjs, tspath.ExtensionJs, tspath.ExtensionJson, tspath.ExtensionDmts, tspath.ExtensionDcts, tspath.ExtensionDts} + for _, ext := range jsAndDtsExtensions { + if tspath.FileExtensionIs(possibleInputBase, ext) { + inputExts := r.getPossibleOriginalInputExtensionForExtension(possibleInputBase) + for _, possibleExt := range inputExts { + if !extensionIsOk(r.extensions, possibleExt) { + continue + } + possibleInputWithInputExtension := tspath.ChangeExtension(possibleInputBase, possibleExt) + if r.resolver.host.FS().FileExists(possibleInputWithInputExtension) { + resolved := r.loadFileNameFromPackageJSONField(r.extensions, possibleInputWithInputExtension, "", false) + if !resolved.shouldContinueSearching() { + return resolved } } } @@ -873,24 +831,6 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string return continueSearching() } -func (r *resolutionState) getCommonSourceDirectory() string { - return outputpaths.GetCommonSourceDirectory( - r.compilerOptions, - func() []string { return []string{} }, // Empty files function for now - r.resolver.host.GetCurrentDirectory(), - r.resolver.host.FS().UseCaseSensitiveFileNames(), - ) -} - -func (r *resolutionState) getCommonSourceDirectoryForFiles(files []string) string { - return outputpaths.GetCommonSourceDirectory( - r.compilerOptions, - func() []string { return files }, - r.resolver.host.GetCurrentDirectory(), - r.resolver.host.FS().UseCaseSensitiveFileNames(), - ) -} - func (r *resolutionState) getOutputDirectoriesForBaseDirectory(commonSourceDirGuess string) []string { // Config file output paths are processed to be relative to the host's current directory, while // otherwise the paths are resolved relative to the common source dir the compiler puts together diff --git a/internal/module/resolver_test.go b/internal/module/resolver_test.go index b7375b18f5..bc106e6cb2 100644 --- a/internal/module/resolver_test.go +++ b/internal/module/resolver_test.go @@ -74,15 +74,21 @@ var skip = []string{ "moduleResolutionWithSymlinks_referenceTypes.ts", "moduleResolutionWithSymlinks_withOutDir.ts", "moduleResolutionWithSymlinks.ts", + "nodeAllowJsPackageSelfName(module=node16).ts", + "nodeAllowJsPackageSelfName(module=nodenext).ts", "nodeAllowJsPackageSelfName2.ts", "nodeModulesAllowJsConditionalPackageExports(module=node16).ts", "nodeModulesAllowJsConditionalPackageExports(module=nodenext).ts", "nodeModulesAllowJsPackageExports(module=node16).ts", "nodeModulesAllowJsPackageExports(module=nodenext).ts", + "nodeModulesAllowJsPackageImports(module=node16).ts", + "nodeModulesAllowJsPackageImports(module=nodenext).ts", "nodeModulesAllowJsPackagePatternExports(module=node16).ts", "nodeModulesAllowJsPackagePatternExports(module=nodenext).ts", "nodeModulesAllowJsPackagePatternExportsTrailers(module=node16).ts", "nodeModulesAllowJsPackagePatternExportsTrailers(module=nodenext).ts", + "nodeModulesConditionalPackageExports(module=node16).ts", + "nodeModulesConditionalPackageExports(module=nodenext).ts", "nodeModulesDeclarationEmitWithPackageExports(module=node16).ts", "nodeModulesDeclarationEmitWithPackageExports(module=nodenext).ts", "nodeModulesExportsBlocksTypesVersions(module=node16).ts", diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt index 331e173d70..d26c2693e1 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt @@ -1,4 +1,5 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -10,8 +11,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export m ".": "./dist/index.js" } } -==== index.ts (0 errors) ==== +==== index.ts (1 errors) ==== import * as me from "@this/package"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. me.thing(); diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff new file mode 100644 index 0000000000..e4db2adb78 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.nodeNextPackageSelfNameWithOutDir.errors.txt ++++ new.nodeNextPackageSelfNameWithOutDir.errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -9, +10 lines =@@ + ".": "./dist/index.js" + } + } +-==== index.ts (0 errors) ==== ++==== index.ts (1 errors) ==== + import * as me from "@this/package"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + me.thing(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols index 80a238b132..a7fc4e2e1d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols @@ -5,9 +5,7 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); ->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) ->thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff new file mode 100644 index 0000000000..81059b55c0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.symbols.diff @@ -0,0 +1,12 @@ +--- old.nodeNextPackageSelfNameWithOutDir.symbols ++++ new.nodeNextPackageSelfNameWithOutDir.symbols +@@= skipped -4, +4 lines =@@ + >me : Symbol(me, Decl(index.ts, 0, 6)) + + me.thing(); +->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) + >me : Symbol(me, Decl(index.ts, 0, 6)) +->thing : Symbol(thing, Decl(index.ts, 2, 11)) + + export function thing(): void {} + >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types index 5b7de921ad..4d89d8bd8b 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : typeof me +>me : any me.thing(); ->me.thing() : void ->me.thing : () => void ->me : typeof me ->thing : () => void +>me.thing() : any +>me.thing : any +>me : any +>thing : any export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff new file mode 100644 index 0000000000..9e8fc2da9e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.types.diff @@ -0,0 +1,21 @@ +--- old.nodeNextPackageSelfNameWithOutDir.types ++++ new.nodeNextPackageSelfNameWithOutDir.types +@@= skipped -1, +1 lines =@@ + + === index.ts === + import * as me from "@this/package"; +->me : typeof me ++>me : any + + me.thing(); +->me.thing() : void +->me.thing : () => void +->me : typeof me +->thing : () => void ++>me.thing() : any ++>me.thing : any ++>me : any ++>thing : any + + export function thing(): void {} + >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt index f9b1cfae73..30c150c783 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt @@ -1,4 +1,5 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -13,8 +14,10 @@ error TS2209: The project root is ambiguous, but is required to resolve export m } } } -==== index.ts (0 errors) ==== +==== index.ts (1 errors) ==== import * as me from "@this/package"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. me.thing(); diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff new file mode 100644 index 0000000000..65d0b7ee4b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff @@ -0,0 +1,20 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt ++++ new.nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -12, +13 lines =@@ + } + } + } +-==== index.ts (0 errors) ==== ++==== index.ts (1 errors) ==== + import * as me from "@this/package"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + me.thing(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols index 23b246200c..9f75119c4a 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols @@ -5,9 +5,7 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); ->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) ->thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff new file mode 100644 index 0000000000..6fa4367955 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.symbols.diff @@ -0,0 +1,12 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDir.symbols ++++ new.nodeNextPackageSelfNameWithOutDirDeclDir.symbols +@@= skipped -4, +4 lines =@@ + >me : Symbol(me, Decl(index.ts, 0, 6)) + + me.thing(); +->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) + >me : Symbol(me, Decl(index.ts, 0, 6)) +->thing : Symbol(thing, Decl(index.ts, 2, 11)) + + export function thing(): void {} + >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types index eb6b45ec9c..5ab49769a5 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : typeof me +>me : any me.thing(); ->me.thing() : void ->me.thing : () => void ->me : typeof me ->thing : () => void +>me.thing() : any +>me.thing : any +>me : any +>thing : any export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff new file mode 100644 index 0000000000..d04e9b6454 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.types.diff @@ -0,0 +1,21 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDir.types ++++ new.nodeNextPackageSelfNameWithOutDirDeclDir.types +@@= skipped -1, +1 lines =@@ + + === index.ts === + import * as me from "@this/package"; +->me : typeof me ++>me : any + + me.thing(); +->me.thing() : void +->me.thing : () => void +->me : typeof me +->thing : () => void ++>me.thing() : any ++>me.thing : any ++>me : any ++>thing : any + + export function thing(): void {} + >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt new file mode 100644 index 0000000000..2915352d08 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt @@ -0,0 +1,34 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "module": "nodenext", + "outDir": "./dist", + "declarationDir": "./types", + "composite": true + } + } +==== index.ts (1 errors) ==== + import * as me from "@this/package"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + me.thing(); + + export function thing(): void {} + +==== package.json (0 errors) ==== + { + "name": "@this/package", + "type": "module", + "exports": { + ".": { + "default": "./dist/index.js", + "types": "./types/index.d.ts" + } + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff new file mode 100644 index 0000000000..2ff246db57 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff @@ -0,0 +1,38 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt +@@= skipped -0, +0 lines =@@ +- ++error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. ++ ++ ++!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++==== tsconfig.json (0 errors) ==== ++ { ++ "compilerOptions": { ++ "module": "nodenext", ++ "outDir": "./dist", ++ "declarationDir": "./types", ++ "composite": true ++ } ++ } ++==== index.ts (1 errors) ==== ++ import * as me from "@this/package"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. ++ ++ me.thing(); ++ ++ export function thing(): void {} ++ ++==== package.json (0 errors) ==== ++ { ++ "name": "@this/package", ++ "type": "module", ++ "exports": { ++ ".": { ++ "default": "./dist/index.js", ++ "types": "./types/index.d.ts" ++ } ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols index 12f74f2167..fad765ba6f 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols @@ -5,9 +5,7 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); ->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) ->thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff new file mode 100644 index 0000000000..ac6c21f8ef --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff @@ -0,0 +1,12 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols +@@= skipped -4, +4 lines =@@ + >me : Symbol(me, Decl(index.ts, 0, 6)) + + me.thing(); +->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) + >me : Symbol(me, Decl(index.ts, 0, 6)) +->thing : Symbol(thing, Decl(index.ts, 2, 11)) + + export function thing(): void {} + >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types index a4654ce72c..0312d872ba 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : typeof me +>me : any me.thing(); ->me.thing() : void ->me.thing : () => void ->me : typeof me ->thing : () => void +>me.thing() : any +>me.thing : any +>me : any +>thing : any export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff new file mode 100644 index 0000000000..5b1a188279 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff @@ -0,0 +1,21 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types +@@= skipped -1, +1 lines =@@ + + === index.ts === + import * as me from "@this/package"; +->me : typeof me ++>me : any + + me.thing(); +->me.thing() : void +->me.thing : () => void +->me : typeof me +->thing : () => void ++>me.thing() : any ++>me.thing : any ++>me : any ++>thing : any + + export function thing(): void {} + >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt new file mode 100644 index 0000000000..9b55776457 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt @@ -0,0 +1,44 @@ +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + +!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "module": "nodenext", + "outDir": "./dist", + "declarationDir": "./types", + "composite": true + } + } +==== index.ts (0 errors) ==== + export {srcthing as thing} from "./src/thing.js"; +==== src/thing.ts (1 errors) ==== + // The following import should cause `index.ts` + // to be included in the build, which will, + // in turn, cause the common src directory to not be `src` + // (the harness is wierd here in that noImplicitReferences makes only + // this file get loaded as an entrypoint and emitted, while on the + // real command-line we'll crawl the imports for that set - a limitation + // of the harness, I suppose) + import * as me from "@this/package"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + me.thing(); + + export function srcthing(): void {} + + +==== package.json (0 errors) ==== + { + "name": "@this/package", + "type": "module", + "exports": { + ".": { + "default": "./dist/index.js", + "types": "./types/index.d.ts" + } + } + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff new file mode 100644 index 0000000000..7365ad807a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff @@ -0,0 +1,48 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt +@@= skipped -0, +0 lines =@@ +- ++error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. ++ ++ ++!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++==== tsconfig.json (0 errors) ==== ++ { ++ "compilerOptions": { ++ "module": "nodenext", ++ "outDir": "./dist", ++ "declarationDir": "./types", ++ "composite": true ++ } ++ } ++==== index.ts (0 errors) ==== ++ export {srcthing as thing} from "./src/thing.js"; ++==== src/thing.ts (1 errors) ==== ++ // The following import should cause `index.ts` ++ // to be included in the build, which will, ++ // in turn, cause the common src directory to not be `src` ++ // (the harness is wierd here in that noImplicitReferences makes only ++ // this file get loaded as an entrypoint and emitted, while on the ++ // real command-line we'll crawl the imports for that set - a limitation ++ // of the harness, I suppose) ++ import * as me from "@this/package"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. ++ ++ me.thing(); ++ ++ export function srcthing(): void {} ++ ++ ++==== package.json (0 errors) ==== ++ { ++ "name": "@this/package", ++ "type": "module", ++ "exports": { ++ ".": { ++ "default": "./dist/index.js", ++ "types": "./types/index.d.ts" ++ } ++ } ++ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols index 0aca3867f1..8325dd2aef 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols @@ -17,9 +17,7 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); ->me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff index a28cda674e..c477bfdd8e 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff @@ -5,10 +5,8 @@ me.thing(); ->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) -+>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) -+>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types index d65e7900aa..21e392eb8b 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : typeof me +>me : any me.thing(); ->me.thing() : void ->me.thing : () => void ->me : typeof me ->thing : () => void +>me.thing() : any +>me.thing : any +>me : any +>thing : any export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff new file mode 100644 index 0000000000..f353a36a66 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff @@ -0,0 +1,21 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types +@@= skipped -13, +13 lines =@@ + // real command-line we'll crawl the imports for that set - a limitation + // of the harness, I suppose) + import * as me from "@this/package"; +->me : typeof me ++>me : any + + me.thing(); +->me.thing() : void +->me.thing : () => void +->me : typeof me +->thing : () => void ++>me.thing() : any ++>me.thing : any ++>me : any ++>thing : any + + export function srcthing(): void {} + >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt index 500d58c848..c69d272c9d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt @@ -1,4 +1,5 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. @@ -13,7 +14,7 @@ error TS2209: The project root is ambiguous, but is required to resolve export m } ==== index.ts (0 errors) ==== export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (0 errors) ==== +==== src/thing.ts (1 errors) ==== // The following import should cause `index.ts` // to be included in the build, which will, // in turn, cause the common src directory to not be `src` @@ -22,6 +23,8 @@ error TS2209: The project root is ambiguous, but is required to resolve export m // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. me.thing(); diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff new file mode 100644 index 0000000000..ab5efeb973 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff @@ -0,0 +1,26 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +@@= skipped -12, +13 lines =@@ + } + ==== index.ts (0 errors) ==== + export {srcthing as thing} from "./src/thing.js"; +-==== src/thing.ts (0 errors) ==== ++==== src/thing.ts (1 errors) ==== + // The following import should cause `index.ts` + // to be included in the build, which will, + // in turn, cause the common src directory to not be `src` +@@= skipped -9, +9 lines =@@ + // real command-line we'll crawl the imports for that set - a limitation + // of the harness, I suppose) + import * as me from "@this/package"; ++ ~~~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + me.thing(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols index f4d32f11a9..0cd32d19d7 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols @@ -17,9 +17,7 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); ->me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff index a622e73c4d..2d5893b203 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff @@ -5,10 +5,8 @@ me.thing(); ->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) -+>me.thing : Symbol(thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) ->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) -+>thing : Symbol(thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types index fe50376388..fa5240b00c 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : typeof me +>me : any me.thing(); ->me.thing() : void ->me.thing : () => void ->me : typeof me ->thing : () => void +>me.thing() : any +>me.thing : any +>me : any +>thing : any export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff new file mode 100644 index 0000000000..6ad9c105ab --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff @@ -0,0 +1,21 @@ +--- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types ++++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types +@@= skipped -13, +13 lines =@@ + // real command-line we'll crawl the imports for that set - a limitation + // of the harness, I suppose) + import * as me from "@this/package"; +->me : typeof me ++>me : any + + me.thing(); +->me.thing() : void +->me.thing : () => void +->me : typeof me +->thing : () => void ++>me.thing() : any ++>me.thing : any ++>me : any ++>thing : any + + export function srcthing(): void {} + >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt index fe6d0aa7e4..4454c8d1b0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt @@ -1,21 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. +index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; -==== index.mjs (0 errors) ==== +==== index.mjs (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; ==== index.cjs (1 errors) ==== // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. self; ==== package.json (0 errors) ==== { diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).types index c1291c3042..e91f9692a5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).types @@ -3,24 +3,24 @@ === index.js === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.mjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.cjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt index fe6d0aa7e4..4454c8d1b0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt @@ -1,21 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. +index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; -==== index.mjs (0 errors) ==== +==== index.mjs (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; ==== index.cjs (1 errors) ==== // esm format file import * as self from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. self; ==== package.json (0 errors) ==== { diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).types index c1291c3042..e91f9692a5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node18).types @@ -3,24 +3,24 @@ === index.js === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.mjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.cjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt index 8ceed405f3..4454c8d1b0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt @@ -1,18 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; -==== index.mjs (0 errors) ==== +==== index.mjs (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; -==== index.cjs (0 errors) ==== +==== index.cjs (1 errors) ==== // esm format file import * as self from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. self; ==== package.json (0 errors) ==== { diff --git a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).types index c1291c3042..e91f9692a5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).types @@ -3,24 +3,24 @@ === index.js === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.mjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any === index.cjs === // esm format file import * as self from "package"; ->self : typeof self +>self : any self; ->self : typeof self +>self : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt index 177d7f86d0..0e7496180a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@ -1,14 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -20,11 +33,17 @@ index.cjs(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -36,15 +55,17 @@ index.cjs(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cjs (2 errors) ==== +==== index.cjs (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js index 62fb2abec9..2f99e51c4c 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -190,27 +206,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js.diff new file mode 100644 index 0000000000..6fd54f278d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).js.diff @@ -0,0 +1,57 @@ +--- old.nodeModulesAllowJsConditionalPackageExports(module=node16).js ++++ new.nodeModulesAllowJsConditionalPackageExports(module=node16).js +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -67, +83 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types index 77f1ff9641..296335f7dc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt index 177d7f86d0..0e7496180a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt @@ -1,14 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -20,11 +33,17 @@ index.cjs(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -36,15 +55,17 @@ index.cjs(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cjs (2 errors) ==== +==== index.cjs (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js index 2e7a6a871b..63608c6079 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -157,27 +173,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js.diff index b2a38682a1..9d4af863a7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).js.diff @@ -1,6 +1,29 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=node18).js +++ new.nodeModulesAllowJsConditionalPackageExports(module=node18).js -@@= skipped -140, +140 lines =@@ +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -18, +34 lines =@@ ts.mjsSource; //// [index.cjs] "use strict"; @@ -58,4 +81,33 @@ +const ts = require("inner/types"); cjsi.cjsSource; mjsi.cjsSource; - typei.implicitCjsSource; \ No newline at end of file + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types index 77f1ff9641..296335f7dc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt index 850d0f056f..0e7496180a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt @@ -1,12 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -18,11 +33,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -34,11 +55,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cjs (0 errors) ==== +==== index.cjs (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js index 62fb2abec9..2f99e51c4c 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -190,27 +206,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js.diff new file mode 100644 index 0000000000..321270cbcb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).js.diff @@ -0,0 +1,57 @@ +--- old.nodeModulesAllowJsConditionalPackageExports(module=nodenext).js ++++ new.nodeModulesAllowJsConditionalPackageExports(module=nodenext).js +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -67, +83 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types index 77f1ff9641..296335f7dc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt index 7433da8ed7..0543bf37ed 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt @@ -1,17 +1,30 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -21,11 +34,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -35,15 +54,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.cjs (3 errors) ==== +==== index.cjs (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js index 208b7a1a36..817ed97973 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -151,25 +165,11 @@ const typei = __importStar(require("inner")); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js.diff new file mode 100644 index 0000000000..4b82b99738 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).js.diff @@ -0,0 +1,53 @@ +--- old.nodeModulesAllowJsPackageExports(module=node16).js ++++ new.nodeModulesAllowJsPackageExports(module=node16).js +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -63, +77 lines =@@ + cjsi; + mjsi; + typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).types index 53d6637e86..794aab4871 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node16).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt index 7433da8ed7..0543bf37ed 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt @@ -1,17 +1,30 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -21,11 +34,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -35,15 +54,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.cjs (3 errors) ==== +==== index.cjs (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js index acd2fda96f..71df78c720 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -118,25 +132,11 @@ const typei = require("inner"); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js.diff index d1e301cc9d..26dc4e113f 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).js.diff @@ -1,6 +1,27 @@ --- old.nodeModulesAllowJsPackageExports(module=node18).js +++ new.nodeModulesAllowJsPackageExports(module=node18).js -@@= skipped -103, +103 lines =@@ +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -16, +30 lines =@@ typei; //// [index.cjs] "use strict"; @@ -42,18 +63,50 @@ -const cjs = __importStar(require("package/cjs")); -const mjs = __importStar(require("package/mjs")); -const type = __importStar(require("package")); -+const cjs = require("package/cjs"); -+const mjs = require("package/mjs"); -+const type = require("package"); - cjs; - mjs; - type; +-cjs; +-mjs; +-type; -const cjsi = __importStar(require("inner/cjs")); -const mjsi = __importStar(require("inner/mjs")); -const typei = __importStar(require("inner")); +-cjsi; +-mjsi; +-typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++const cjs = require("package/cjs"); ++const mjs = require("package/mjs"); ++const type = require("package"); ++cjs; ++mjs; ++type; +const cjsi = require("inner/cjs"); +const mjsi = require("inner/mjs"); +const typei = require("inner"); - cjsi; - mjsi; - typei; \ No newline at end of file ++cjsi; ++mjsi; ++typei; ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).types index 53d6637e86..794aab4871 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=node18).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt index 42a27cf192..4297bbb071 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt @@ -1,12 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -16,11 +31,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m cjsi; mjsi; typei; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -30,11 +51,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m cjsi; mjsi; typei; -==== index.cjs (0 errors) ==== +==== index.cjs (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js index 208b7a1a36..817ed97973 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -151,25 +165,11 @@ const typei = __importStar(require("inner")); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js.diff new file mode 100644 index 0000000000..66c28515a1 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).js.diff @@ -0,0 +1,53 @@ +--- old.nodeModulesAllowJsPackageExports(module=nodenext).js ++++ new.nodeModulesAllowJsPackageExports(module=nodenext).js +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -63, +77 lines =@@ + cjsi; + mjsi; + typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types index 53d6637e86..794aab4871 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types @@ -3,22 +3,22 @@ === index.js === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mjs === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cjs === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt index e845dc72f0..6aecf9a590 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt @@ -1,34 +1,55 @@ error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.cjs (2 errors) ==== +==== index.cjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#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("#mjs")' call instead. +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; ~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js index 510e6b7128..ca3aa0ac43 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js @@ -37,6 +37,14 @@ type; } } +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; //// [index.mjs] // esm format file import * as cjs from "#cjs"; @@ -88,19 +96,11 @@ const type = __importStar(require("#type")); cjs; mjs; type; -//// [index.js] -// esm format file -import * as cjs from "#cjs"; -import * as mjs from "#mjs"; -import * as type from "#type"; -cjs; -mjs; -type; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js.diff new file mode 100644 index 0000000000..0f2802e9b2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).js.diff @@ -0,0 +1,41 @@ +--- old.nodeModulesAllowJsPackageImports(module=node16).js ++++ new.nodeModulesAllowJsPackageImports(module=node16).js +@@= skipped -36, +36 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "#cjs"; ++import * as mjs from "#mjs"; ++import * as type from "#type"; ++cjs; ++mjs; ++type; + //// [index.mjs] + // esm format file + import * as cjs from "#cjs"; +@@= skipped -51, +59 lines =@@ + cjs; + mjs; + type; +-//// [index.js] +-// esm format file +-import * as cjs from "#cjs"; +-import * as mjs from "#mjs"; +-import * as type from "#type"; +-cjs; +-mjs; +-type; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).types index b3f59ab58a..12122d2613 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node16).types @@ -3,60 +3,60 @@ === index.js === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.mjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.cjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt index e845dc72f0..6aecf9a590 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt @@ -1,34 +1,55 @@ error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.cjs (2 errors) ==== +==== index.cjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#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("#mjs")' call instead. +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; ~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js index 85adfd4979..f6dffbaa4d 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js @@ -37,6 +37,14 @@ type; } } +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; //// [index.mjs] // esm format file import * as cjs from "#cjs"; @@ -55,19 +63,11 @@ const type = require("#type"); cjs; mjs; type; -//// [index.js] -// esm format file -import * as cjs from "#cjs"; -import * as mjs from "#mjs"; -import * as type from "#type"; -cjs; -mjs; -type; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js.diff index ee6583bebc..2b0d5022be 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).js.diff @@ -1,6 +1,21 @@ --- old.nodeModulesAllowJsPackageImports(module=node18).js +++ new.nodeModulesAllowJsPackageImports(module=node18).js -@@= skipped -46, +46 lines =@@ +@@= skipped -36, +36 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "#cjs"; ++import * as mjs from "#mjs"; ++import * as type from "#type"; ++cjs; ++mjs; ++type; + //// [index.mjs] + // esm format file + import * as cjs from "#cjs"; +@@= skipped -10, +18 lines =@@ type; //// [index.cjs] "use strict"; @@ -42,9 +57,32 @@ -const cjs = __importStar(require("#cjs")); -const mjs = __importStar(require("#mjs")); -const type = __importStar(require("#type")); +-cjs; +-mjs; +-type; +-//// [index.js] +-// esm format file +-import * as cjs from "#cjs"; +-import * as mjs from "#mjs"; +-import * as type from "#type"; +-cjs; +-mjs; +-type; +- +- +const cjs = require("#cjs"); +const mjs = require("#mjs"); +const type = require("#type"); - cjs; - mjs; - type; \ No newline at end of file ++cjs; ++mjs; ++type; ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).types index b3f59ab58a..12122d2613 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=node18).types @@ -3,60 +3,60 @@ === index.js === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.mjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.cjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt index ebcc53aeb3..6aecf9a590 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt @@ -1,28 +1,55 @@ error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. +index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. +index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. +index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.js (0 errors) ==== +==== index.js (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.mjs (0 errors) ==== +==== index.mjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; -==== index.cjs (0 errors) ==== +==== index.cjs (3 errors) ==== // esm format file import * as cjs from "#cjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. import * as mjs from "#mjs"; + ~~~~~~ +!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. import * as type from "#type"; + ~~~~~~~ +!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js index 510e6b7128..ca3aa0ac43 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js @@ -37,6 +37,14 @@ type; } } +//// [index.js] +// esm format file +import * as cjs from "#cjs"; +import * as mjs from "#mjs"; +import * as type from "#type"; +cjs; +mjs; +type; //// [index.mjs] // esm format file import * as cjs from "#cjs"; @@ -88,19 +96,11 @@ const type = __importStar(require("#type")); cjs; mjs; type; -//// [index.js] -// esm format file -import * as cjs from "#cjs"; -import * as mjs from "#mjs"; -import * as type from "#type"; -cjs; -mjs; -type; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js.diff new file mode 100644 index 0000000000..8b77fd6aeb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).js.diff @@ -0,0 +1,41 @@ +--- old.nodeModulesAllowJsPackageImports(module=nodenext).js ++++ new.nodeModulesAllowJsPackageImports(module=nodenext).js +@@= skipped -36, +36 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "#cjs"; ++import * as mjs from "#mjs"; ++import * as type from "#type"; ++cjs; ++mjs; ++type; + //// [index.mjs] + // esm format file + import * as cjs from "#cjs"; +@@= skipped -51, +59 lines =@@ + cjs; + mjs; + type; +-//// [index.js] +-// esm format file +-import * as cjs from "#cjs"; +-import * as mjs from "#mjs"; +-import * as type from "#type"; +-cjs; +-mjs; +-type; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types index b3f59ab58a..12122d2613 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types @@ -3,60 +3,60 @@ === index.js === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.mjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any === index.cjs === // esm format file import * as cjs from "#cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "#mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "#type"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt index 440a46e1ec..35c27166e7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt @@ -1,14 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -20,11 +33,17 @@ index.cts(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -36,15 +55,17 @@ index.cts(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cts (2 errors) ==== +==== index.cts (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff index 7c61f43cb2..db9b2c18e8 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).errors.txt.diff @@ -2,14 +2,116 @@ +++ new.nodeModulesConditionalPackageExports(module=node16).errors.txt @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. +-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. +-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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -57, +55 lines =@@ +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cts (2 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -57, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js index 7948f14a95..87d5cda21c 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -190,27 +206,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js.diff new file mode 100644 index 0000000000..5a8f5c9077 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).js.diff @@ -0,0 +1,57 @@ +--- old.nodeModulesConditionalPackageExports(module=node16).js ++++ new.nodeModulesConditionalPackageExports(module=node16).js +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -67, +83 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types index b90aa9f028..548c7f4fc2 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types.diff index 970cae843b..b5d4494171 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node16).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesConditionalPackageExports(module=node16).types +++ new.nodeModulesConditionalPackageExports(module=node16).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt index 440a46e1ec..35c27166e7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt @@ -1,14 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -20,11 +33,17 @@ index.cts(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -36,15 +55,17 @@ index.cts(4,23): error TS1479: The current file is a CommonJS module whose impor mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cts (2 errors) ==== +==== index.cts (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff index 0411cc93c5..9f08cb4b48 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).errors.txt.diff @@ -2,14 +2,116 @@ +++ new.nodeModulesConditionalPackageExports(module=node18).errors.txt @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. +-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. +-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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -57, +55 lines =@@ +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cts (2 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -57, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js index 57a3865f78..f9843b3e1b 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -157,27 +173,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js.diff index 7f755a6060..fbf3a6575b 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).js.diff @@ -1,6 +1,29 @@ --- old.nodeModulesConditionalPackageExports(module=node18).js +++ new.nodeModulesConditionalPackageExports(module=node18).js -@@= skipped -140, +140 lines =@@ +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -18, +34 lines =@@ ts.mjsSource; //// [index.cjs] "use strict"; @@ -58,4 +81,33 @@ +const ts = require("inner/types"); cjsi.cjsSource; mjsi.cjsSource; - typei.implicitCjsSource; \ No newline at end of file + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types index b90aa9f028..548c7f4fc2 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types.diff index 6c697d20b0..5d552d69c5 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=node18).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesConditionalPackageExports(module=node18).types +++ new.nodeModulesConditionalPackageExports(module=node18).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt index b08caf68e1..35c27166e7 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt @@ -1,12 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -18,11 +33,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -34,11 +55,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m mjsi.mjsSource; typei.mjsSource; ts.mjsSource; -==== index.cts (0 errors) ==== +==== index.cts (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff index 0584fe2f8a..e5d6ca3d03 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt.diff @@ -4,10 +4,110 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -51, +49 lines =@@ +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cts (0 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -51, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js index 7948f14a95..87d5cda21c 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js @@ -123,6 +123,22 @@ export const cjsSource = true; } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/a"; +import * as mjsi from "inner/b"; +import * as typei from "inner"; +import * as ts from "inner/types"; +cjsi.mjsSource; +mjsi.mjsSource; +typei.mjsSource; +ts.mjsSource; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -190,27 +206,11 @@ cjsi.cjsSource; mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/a"; -import * as mjsi from "inner/b"; -import * as typei from "inner"; -import * as ts from "inner/types"; -cjsi.mjsSource; -mjsi.mjsSource; -typei.mjsSource; -ts.mjsSource; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js.diff new file mode 100644 index 0000000000..f1050b1157 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).js.diff @@ -0,0 +1,57 @@ +--- old.nodeModulesConditionalPackageExports(module=nodenext).js ++++ new.nodeModulesConditionalPackageExports(module=nodenext).js +@@= skipped -122, +122 lines =@@ + } + + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/a"; ++import * as mjsi from "inner/b"; ++import * as typei from "inner"; ++import * as ts from "inner/types"; ++cjsi.mjsSource; ++mjsi.mjsSource; ++typei.mjsSource; ++ts.mjsSource; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -67, +83 lines =@@ + mjsi.cjsSource; + typei.implicitCjsSource; + ts.cjsSource; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/a"; +-import * as mjsi from "inner/b"; +-import * as typei from "inner"; +-import * as ts from "inner/types"; +-cjsi.mjsSource; +-mjsi.mjsSource; +-typei.mjsSource; +-ts.mjsSource; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types index b90aa9f028..548c7f4fc2 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -55,22 +55,22 @@ ts.mjsSource; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi @@ -107,22 +107,22 @@ ts.mjsSource; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/a"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types.diff index 755f4a924e..0fc79c354b 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesConditionalPackageExports(module=nodenext).types +++ new.nodeModulesConditionalPackageExports(module=nodenext).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt index f2737ac29f..7de8927f25 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt @@ -1,7 +1,14 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. @@ -10,11 +17,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -24,11 +37,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -38,15 +57,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.cts (3 errors) ==== +==== index.cts (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff new file mode 100644 index 0000000000..73553cbdb4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff @@ -0,0 +1,108 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + 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. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + 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. + node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. + node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. +@@= skipped -9, +16 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.cts (3 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.cts (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + export const a = cjs; + export const b = mjs; + export const c = type; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js index db97947085..cec3b8c991 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js @@ -91,6 +91,20 @@ export const cjsNonmain = true; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -155,58 +169,32 @@ const typei = __importStar(require("inner")); exports.d = cjsi; exports.e = mjsi; exports.f = typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export const a = cjs; -export const b = mjs; -export const c = type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -export const d = cjsi; -export const e = mjsi; -export const f = typei; -//// [index.d.mts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.ts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.cts] -// cjs format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.mts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.ts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.cts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js.diff index 48d94cd137..021f0c8268 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).js.diff @@ -1,26 +1,94 @@ --- old.nodeModulesDeclarationEmitWithPackageExports(module=node16).js +++ new.nodeModulesDeclarationEmitWithPackageExports(module=node16).js -@@= skipped -171, +171 lines =@@ +@@= skipped -90, +90 lines =@@ + } + } - - //// [index.d.mts] ++//// [index.js] +// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++export const a = cjs; ++export const b = mjs; ++export const c = type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++export const d = cjsi; ++export const e = mjsi; ++export const f = typei; + //// [index.mjs] + // esm format file import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ +@@= skipped -64, +78 lines =@@ + exports.d = cjsi; + exports.e = mjsi; + exports.f = typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export const a = cjs; +-export const b = mjs; +-export const c = type; ++ ++ ++//// [index.d.ts] ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +-export const d = cjsi; +-export const e = mjsi; +-export const f = typei; +- +- ++export declare const d: typeof cjsi; ++export declare const e: typeof mjsi; ++export declare const f: typeof typei; + //// [index.d.mts] +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +@@= skipped -30, +23 lines =@@ export declare const e: typeof mjsi; export declare const f: typeof typei; //// [index.d.cts] -+// cjs format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ - export declare const e: typeof mjsi; - export declare const f: typeof typei; - //// [index.d.ts] -+// esm format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; \ No newline at end of file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-export declare const d: typeof cjsi; +-export declare const e: typeof mjsi; +-export declare const f: typeof typei; +-//// [index.d.ts] +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types index 944099872b..182f0977bc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types @@ -3,25 +3,25 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -47,25 +47,25 @@ export const f = typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -91,25 +91,25 @@ export const f = typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types.diff new file mode 100644 index 0000000000..57724ef3fe --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).types.diff @@ -0,0 +1,107 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=node16).types ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=node16).types +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt index f2737ac29f..7de8927f25 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt @@ -1,7 +1,14 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. @@ -10,11 +17,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -24,11 +37,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -38,15 +57,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.cts (3 errors) ==== +==== index.cts (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff new file mode 100644 index 0000000000..783da0f98a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff @@ -0,0 +1,108 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + 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. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + 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. + node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. + node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. +@@= skipped -9, +16 lines =@@ + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.cts (3 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.cts (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + export const a = cjs; + export const b = mjs; + export const c = type; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js index d13987b541..e5c52ba9ab 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js @@ -91,6 +91,20 @@ export const cjsNonmain = true; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -122,58 +136,32 @@ const typei = require("inner"); exports.d = cjsi; exports.e = mjsi; exports.f = typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export const a = cjs; -export const b = mjs; -export const c = type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -export const d = cjsi; -export const e = mjsi; -export const f = typei; -//// [index.d.mts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.ts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.cts] -// cjs format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.mts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.ts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.cts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js.diff index 4443916e75..1e02f710e6 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).js.diff @@ -1,6 +1,27 @@ --- old.nodeModulesDeclarationEmitWithPackageExports(module=node18).js +++ new.nodeModulesDeclarationEmitWithPackageExports(module=node18).js -@@= skipped -106, +106 lines =@@ +@@= skipped -90, +90 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++export const a = cjs; ++export const b = mjs; ++export const c = type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++export const d = cjsi; ++export const e = mjsi; ++export const f = typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -16, +30 lines =@@ export const f = typei; //// [index.cjs] "use strict"; @@ -58,27 +79,70 @@ exports.d = cjsi; exports.e = mjsi; exports.f = typei; -@@= skipped -65, +32 lines =@@ - - +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export const a = cjs; +-export const b = mjs; +-export const c = type; ++ ++ ++//// [index.d.ts] ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +-export const d = cjsi; +-export const e = mjsi; +-export const f = typei; +- +- ++export declare const d: typeof cjsi; ++export declare const e: typeof mjsi; ++export declare const f: typeof typei; //// [index.d.mts] -+// esm format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +@@= skipped -78, +38 lines =@@ export declare const e: typeof mjsi; export declare const f: typeof typei; //// [index.d.cts] -+// cjs format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ - export declare const e: typeof mjsi; - export declare const f: typeof typei; - //// [index.d.ts] -+// esm format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; \ No newline at end of file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-export declare const d: typeof cjsi; +-export declare const e: typeof mjsi; +-export declare const f: typeof typei; +-//// [index.d.ts] +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types index 944099872b..182f0977bc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types @@ -3,25 +3,25 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -47,25 +47,25 @@ export const f = typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -91,25 +91,25 @@ export const f = typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types.diff new file mode 100644 index 0000000000..0e8041ff08 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).types.diff @@ -0,0 +1,107 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=node18).types ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=node18).types +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt index ed1769f353..0dbba02dff 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt @@ -1,15 +1,30 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -19,11 +34,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; @@ -33,11 +54,17 @@ node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in export const d = cjsi; export const e = mjsi; export const f = typei; -==== index.cts (0 errors) ==== +==== index.cts (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. export const a = cjs; export const b = mjs; export const c = type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff new file mode 100644 index 0000000000..3aafdb3bf0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff @@ -0,0 +1,102 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + node_modules/inner/index.d.cts(5,1): error TS1036: Statements are not allowed in ambient contexts. + node_modules/inner/index.d.mts(5,1): error TS1036: Statements are not allowed in ambient contexts. + node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- export const a = cjs; +- export const b = mjs; +- export const c = type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- export const d = cjsi; +- export const e = mjsi; +- export const f = typei; +-==== index.cts (0 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ export const a = cjs; ++ export const b = mjs; ++ export const c = type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ export const d = cjsi; ++ export const e = mjsi; ++ export const f = typei; ++==== index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + export const a = cjs; + export const b = mjs; + export const c = type; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js index db97947085..cec3b8c991 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js @@ -91,6 +91,20 @@ export const cjsNonmain = true; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +export const a = cjs; +export const b = mjs; +export const c = type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +export const d = cjsi; +export const e = mjsi; +export const f = typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -155,58 +169,32 @@ const typei = __importStar(require("inner")); exports.d = cjsi; exports.e = mjsi; exports.f = typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export const a = cjs; -export const b = mjs; -export const c = type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -export const d = cjsi; -export const e = mjsi; -export const f = typei; -//// [index.d.mts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.ts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.cts] -// cjs format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.mts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; export declare const d: typeof cjsi; export declare const e: typeof mjsi; export declare const f: typeof typei; -//// [index.d.ts] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -export declare const a: typeof cjs; -export declare const b: typeof mjs; -export declare const c: typeof type; +//// [index.d.cts] +export declare const a: any; +export declare const b: any; +export declare const c: any; import * as cjsi from "inner/cjs"; import * as mjsi from "inner/mjs"; import * as typei from "inner"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js.diff index f1844e2dd5..eb159540ea 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js.diff @@ -1,26 +1,94 @@ --- old.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js +++ new.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).js -@@= skipped -171, +171 lines =@@ +@@= skipped -90, +90 lines =@@ + } + } - - //// [index.d.mts] ++//// [index.js] +// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++export const a = cjs; ++export const b = mjs; ++export const c = type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++export const d = cjsi; ++export const e = mjsi; ++export const f = typei; + //// [index.mjs] + // esm format file import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ +@@= skipped -64, +78 lines =@@ + exports.d = cjsi; + exports.e = mjsi; + exports.f = typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export const a = cjs; +-export const b = mjs; +-export const c = type; ++ ++ ++//// [index.d.ts] ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +-export const d = cjsi; +-export const e = mjsi; +-export const f = typei; +- +- ++export declare const d: typeof cjsi; ++export declare const e: typeof mjsi; ++export declare const f: typeof typei; + //// [index.d.mts] +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; +@@= skipped -30, +23 lines =@@ export declare const e: typeof mjsi; export declare const f: typeof typei; //// [index.d.cts] -+// cjs format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; -@@= skipped -13, +14 lines =@@ - export declare const e: typeof mjsi; - export declare const f: typeof typei; - //// [index.d.ts] -+// esm format file - import * as cjs from "package/cjs"; - import * as mjs from "package/mjs"; - import * as type from "package"; \ No newline at end of file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-export declare const d: typeof cjsi; +-export declare const e: typeof mjsi; +-export declare const f: typeof typei; +-//// [index.d.ts] +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-export declare const a: typeof cjs; +-export declare const b: typeof mjs; +-export declare const c: typeof type; ++export declare const a: any; ++export declare const b: any; ++export declare const c: any; + import * as cjsi from "inner/cjs"; + import * as mjsi from "inner/mjs"; + import * as typei from "inner"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types index 944099872b..182f0977bc 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types @@ -3,25 +3,25 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -47,25 +47,25 @@ export const f = typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -91,25 +91,25 @@ export const f = typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any export const a = cjs; ->a : typeof cjs ->cjs : typeof cjs +>a : any +>cjs : any export const b = mjs; ->b : typeof mjs ->mjs : typeof mjs +>b : any +>mjs : any export const c = type; ->c : typeof type ->type : typeof type +>c : any +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types.diff new file mode 100644 index 0000000000..ae41c0e252 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types.diff @@ -0,0 +1,107 @@ +--- old.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types ++++ new.nodeModulesDeclarationEmitWithPackageExports(module=nodenext).types +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi +@@= skipped -44, +44 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + export const a = cjs; +->a : typeof cjs +->cjs : typeof cjs ++>a : any ++>cjs : any + + export const b = mjs; +->b : typeof mjs +->mjs : typeof mjs ++>b : any ++>mjs : any + + export const c = type; +->c : typeof type +->type : typeof type ++>c : any ++>type : any + + import * as cjsi from "inner/cjs"; + >cjsi : typeof cjsi \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt index 06b2bc6d3e..c3a3b37e59 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt @@ -1,17 +1,30 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -21,11 +34,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -35,15 +54,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.cts (3 errors) ==== +==== index.cts (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff index fc6ff436f0..416acbdd60 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).errors.txt.diff @@ -1,14 +1,111 @@ --- old.nodeModulesPackageExports(module=node16).errors.txt +++ new.nodeModulesPackageExports(module=node16).errors.txt -@@= skipped -2, +2 lines =@@ - 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. +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. 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. -@@= skipped -53, +52 lines =@@ + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cts (3 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cts (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -55, +75 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js index 7d1a5738c7..53f53dc3c1 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -151,25 +165,11 @@ const typei = __importStar(require("inner")); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js.diff new file mode 100644 index 0000000000..8d29012f51 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).js.diff @@ -0,0 +1,53 @@ +--- old.nodeModulesPackageExports(module=node16).js ++++ new.nodeModulesPackageExports(module=node16).js +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -63, +77 lines =@@ + cjsi; + mjsi; + typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types index 91545a2fd7..67faa06aa6 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types.diff index 5d66cd5bfc..edf00e2a30 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node16).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesPackageExports(module=node16).types +++ new.nodeModulesPackageExports(module=node16).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt index 06b2bc6d3e..c3a3b37e59 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt @@ -1,17 +1,30 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -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. -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. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. 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 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -21,11 +34,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -35,15 +54,17 @@ node_modules/inner/index.d.ts(3,22): error TS1479: The current file is a CommonJ cjsi; mjsi; typei; -==== index.cts (3 errors) ==== +==== index.cts (4 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/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("package/mjs")' call instead. +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; ~~~~~~~~~ -!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff index 1f1f2c7f11..b95e8cb421 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).errors.txt.diff @@ -1,14 +1,111 @@ --- old.nodeModulesPackageExports(module=node18).errors.txt +++ new.nodeModulesPackageExports(module=node18).errors.txt -@@= skipped -2, +2 lines =@@ - 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. +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. 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. -@@= skipped -53, +52 lines =@@ + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cts (3 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cts (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -55, +75 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js index afeca4d652..495945686c 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -118,25 +132,11 @@ const typei = require("inner"); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js.diff index 684c35f444..646830d128 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).js.diff @@ -1,6 +1,27 @@ --- old.nodeModulesPackageExports(module=node18).js +++ new.nodeModulesPackageExports(module=node18).js -@@= skipped -103, +103 lines =@@ +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -16, +30 lines =@@ typei; //// [index.cjs] "use strict"; @@ -42,18 +63,50 @@ -const cjs = __importStar(require("package/cjs")); -const mjs = __importStar(require("package/mjs")); -const type = __importStar(require("package")); -+const cjs = require("package/cjs"); -+const mjs = require("package/mjs"); -+const type = require("package"); - cjs; - mjs; - type; +-cjs; +-mjs; +-type; -const cjsi = __importStar(require("inner/cjs")); -const mjsi = __importStar(require("inner/mjs")); -const typei = __importStar(require("inner")); +-cjsi; +-mjsi; +-typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++const cjs = require("package/cjs"); ++const mjs = require("package/mjs"); ++const type = require("package"); ++cjs; ++mjs; ++type; +const cjsi = require("inner/cjs"); +const mjsi = require("inner/mjs"); +const typei = require("inner"); - cjsi; - mjsi; - typei; \ No newline at end of file ++cjsi; ++mjsi; ++typei; ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types index 91545a2fd7..67faa06aa6 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types.diff index e7aec06a09..7d89191a71 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=node18).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesPackageExports(module=node18).types +++ new.nodeModulesPackageExports(module=node18).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt index 64026b31c7..965adec9a2 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt @@ -1,12 +1,27 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. +index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. +index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. +index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== index.ts (0 errors) ==== +==== index.ts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -16,11 +31,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m cjsi; mjsi; typei; -==== index.mts (0 errors) ==== +==== index.mts (3 errors) ==== // esm format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; @@ -30,11 +51,17 @@ error TS2209: The project root is ambiguous, but is required to resolve export m cjsi; mjsi; typei; -==== index.cts (0 errors) ==== +==== index.cts (3 errors) ==== // cjs format file import * as cjs from "package/cjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. import * as mjs from "package/mjs"; + ~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. import * as type from "package"; + ~~~~~~~~~ +!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. cjs; mjs; type; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff index b42f74a3e3..959f1e7201 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt.diff @@ -3,10 +3,102 @@ @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.ts(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.ts(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.ts(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -44, +43 lines =@@ +-==== index.ts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mts (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cts (0 errors) ==== ++==== index.ts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mts (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cts (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -44, +70 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js index 7d1a5738c7..53f53dc3c1 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js @@ -88,6 +88,20 @@ export { type }; } } +//// [index.js] +// esm format file +import * as cjs from "package/cjs"; +import * as mjs from "package/mjs"; +import * as type from "package"; +cjs; +mjs; +type; +import * as cjsi from "inner/cjs"; +import * as mjsi from "inner/mjs"; +import * as typei from "inner"; +cjsi; +mjsi; +typei; //// [index.mjs] // esm format file import * as cjs from "package/cjs"; @@ -151,25 +165,11 @@ const typei = __importStar(require("inner")); cjsi; mjsi; typei; -//// [index.js] -// esm format file -import * as cjs from "package/cjs"; -import * as mjs from "package/mjs"; -import * as type from "package"; -cjs; -mjs; -type; -import * as cjsi from "inner/cjs"; -import * as mjsi from "inner/mjs"; -import * as typei from "inner"; -cjsi; -mjsi; -typei; +//// [index.d.ts] +export {}; //// [index.d.mts] export {}; //// [index.d.cts] export {}; -//// [index.d.ts] -export {}; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js.diff new file mode 100644 index 0000000000..e6df4ccb71 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).js.diff @@ -0,0 +1,53 @@ +--- old.nodeModulesPackageExports(module=nodenext).js ++++ new.nodeModulesPackageExports(module=nodenext).js +@@= skipped -87, +87 lines =@@ + } + } + ++//// [index.js] ++// esm format file ++import * as cjs from "package/cjs"; ++import * as mjs from "package/mjs"; ++import * as type from "package"; ++cjs; ++mjs; ++type; ++import * as cjsi from "inner/cjs"; ++import * as mjsi from "inner/mjs"; ++import * as typei from "inner"; ++cjsi; ++mjsi; ++typei; + //// [index.mjs] + // esm format file + import * as cjs from "package/cjs"; +@@= skipped -63, +77 lines =@@ + cjsi; + mjsi; + typei; +-//// [index.js] +-// esm format file +-import * as cjs from "package/cjs"; +-import * as mjs from "package/mjs"; +-import * as type from "package"; +-cjs; +-mjs; +-type; +-import * as cjsi from "inner/cjs"; +-import * as mjsi from "inner/mjs"; +-import * as typei from "inner"; +-cjsi; +-mjsi; +-typei; +- +- ++ ++ ++//// [index.d.ts] ++export {}; + //// [index.d.mts] + export {}; + //// [index.d.cts] +-export {}; +-//// [index.d.ts] + export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types index 91545a2fd7..67faa06aa6 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types @@ -3,22 +3,22 @@ === index.ts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -41,22 +41,22 @@ typei; === index.mts === // esm format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi @@ -79,22 +79,22 @@ typei; === index.cts === // cjs format file import * as cjs from "package/cjs"; ->cjs : typeof cjs +>cjs : any import * as mjs from "package/mjs"; ->mjs : typeof mjs +>mjs : any import * as type from "package"; ->type : typeof type +>type : any cjs; ->cjs : typeof cjs +>cjs : any mjs; ->mjs : typeof mjs +>mjs : any type; ->type : typeof type +>type : any import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types.diff index 978703cae3..9730a78e76 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesPackageExports(module=nodenext).types +++ new.nodeModulesPackageExports(module=nodenext).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.ts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mts === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cts === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff new file mode 100644 index 0000000000..0421736050 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff @@ -0,0 +1,34 @@ +--- old.nodeAllowJsPackageSelfName(module=node16).errors.txt ++++ new.nodeAllowJsPackageSelfName(module=node16).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. ++index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== ++==== index.js (1 errors) ==== + // esm format file + import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + self; +-==== index.mjs (0 errors) ==== ++==== index.mjs (1 errors) ==== + // esm format file + import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + self; + ==== index.cjs (1 errors) ==== + // esm format file + import * as self from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + self; + ==== package.json (0 errors) ==== + { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).types.diff new file mode 100644 index 0000000000..79579e2c3d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).types.diff @@ -0,0 +1,32 @@ +--- old.nodeAllowJsPackageSelfName(module=node16).types ++++ new.nodeAllowJsPackageSelfName(module=node16).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.mjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.cjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff new file mode 100644 index 0000000000..636c794545 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff @@ -0,0 +1,34 @@ +--- old.nodeAllowJsPackageSelfName(module=node18).errors.txt ++++ new.nodeAllowJsPackageSelfName(module=node18).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. ++index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== ++==== index.js (1 errors) ==== + // esm format file + import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + self; +-==== index.mjs (0 errors) ==== ++==== index.mjs (1 errors) ==== + // esm format file + import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + self; + ==== index.cjs (1 errors) ==== + // esm format file + import * as self from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + self; + ==== package.json (0 errors) ==== + { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).types.diff new file mode 100644 index 0000000000..993201ddcc --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).types.diff @@ -0,0 +1,32 @@ +--- old.nodeAllowJsPackageSelfName(module=node18).types ++++ new.nodeAllowJsPackageSelfName(module=node18).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.mjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.cjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff new file mode 100644 index 0000000000..04b57f5a08 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff @@ -0,0 +1,41 @@ +--- old.nodeAllowJsPackageSelfName(module=nodenext).errors.txt ++++ new.nodeAllowJsPackageSelfName(module=nodenext).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.cjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. + + + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as self from "package"; +- self; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as self from "package"; +- self; +-==== index.cjs (0 errors) ==== +- // esm format file +- import * as self from "package"; ++==== index.js (1 errors) ==== ++ // esm format file ++ import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ self; ++==== index.mjs (1 errors) ==== ++ // esm format file ++ import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ self; ++==== index.cjs (1 errors) ==== ++ // esm format file ++ import * as self from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + self; + ==== package.json (0 errors) ==== + { \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).types.diff new file mode 100644 index 0000000000..8a0fbd3733 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).types.diff @@ -0,0 +1,32 @@ +--- old.nodeAllowJsPackageSelfName(module=nodenext).types ++++ new.nodeAllowJsPackageSelfName(module=nodenext).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.mjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any + + === index.cjs === + // esm format file + import * as self from "package"; +->self : typeof self ++>self : any + + self; +->self : typeof self ++>self : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff index fa6d7597dc..e08d1da38d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt.diff @@ -2,14 +2,116 @@ +++ new.nodeModulesAllowJsConditionalPackageExports(module=node16).errors.txt @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. +-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. +-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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -57, +55 lines =@@ +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cjs (2 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cjs (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -57, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types.diff index f0596cf245..2dffe05f69 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node16).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=node16).types +++ new.nodeModulesAllowJsConditionalPackageExports(module=node16).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff index 7cb6fd0a76..1dc19bd5b1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt.diff @@ -2,14 +2,116 @@ +++ new.nodeModulesAllowJsConditionalPackageExports(module=node18).errors.txt @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. - 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. - 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. +-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. +-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. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -57, +55 lines =@@ +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cjs (2 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cjs (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -57, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types.diff index e8981477a2..d7b146de5d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=node18).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=node18).types +++ new.nodeModulesAllowJsConditionalPackageExports(module=node18).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff index b369a06955..2ef14964d2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt.diff @@ -4,10 +4,110 @@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.mts(2,13): error TS2303: Circular definition of import alias 'cjs'. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -51, +49 lines =@@ +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/a"; +- import * as mjsi from "inner/b"; +- import * as typei from "inner"; +- import * as ts from "inner/types"; +- cjsi.mjsSource; +- mjsi.mjsSource; +- typei.mjsSource; +- ts.mjsSource; +-==== index.cjs (0 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/a"; ++ import * as mjsi from "inner/b"; ++ import * as typei from "inner"; ++ import * as ts from "inner/types"; ++ cjsi.mjsSource; ++ mjsi.mjsSource; ++ typei.mjsSource; ++ ts.mjsSource; ++==== index.cjs (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -51, +76 lines =@@ mjsi.cjsSource; typei.implicitCjsSource; ts.cjsSource; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types.diff index 77f3f24530..68322d3ac2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).types.diff @@ -1,6 +1,93 @@ --- old.nodeModulesAllowJsConditionalPackageExports(module=nodenext).types +++ new.nodeModulesAllowJsConditionalPackageExports(module=nodenext).types -@@= skipped -130, +130 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -52, +52 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/a"; + >cjsi : typeof cjsi +@@= skipped -24, +24 lines =@@ >mjsi : typeof cjsi import * as typei from "inner"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff index c5a0e95651..e593bff0b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).errors.txt.diff @@ -1,14 +1,111 @@ --- old.nodeModulesAllowJsPackageExports(module=node16).errors.txt +++ new.nodeModulesAllowJsPackageExports(module=node16).errors.txt -@@= skipped -2, +2 lines =@@ - 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. +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. 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. -@@= skipped -53, +52 lines =@@ + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cjs (3 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cjs (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -55, +75 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).types.diff index 470716ed80..fef834137b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node16).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesAllowJsPackageExports(module=node16).types +++ new.nodeModulesAllowJsPackageExports(module=node16).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff index 805312f63f..7df9bf176f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).errors.txt.diff @@ -1,14 +1,111 @@ --- old.nodeModulesAllowJsPackageExports(module=node18).errors.txt +++ new.nodeModulesAllowJsPackageExports(module=node18).errors.txt -@@= skipped -2, +2 lines =@@ - 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. +@@= skipped -0, +0 lines =@@ + error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. 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. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. 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. -@@= skipped -53, +52 lines =@@ + !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cjs (3 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cjs (4 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/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("package/mjs")' call instead. ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; + ~~~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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 TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -55, +75 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).types.diff index 48e501c428..0cb07ae47e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=node18).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesAllowJsPackageExports(module=node18).types +++ new.nodeModulesAllowJsPackageExports(module=node18).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff index 27d47037fe..c15c3e629d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt.diff @@ -3,10 +3,102 @@ @@= skipped -0, +0 lines =@@ error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -node_modules/inner/index.d.ts(2,13): error TS2303: Circular definition of import alias 'cjs'. ++index.cjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module 'package' or its corresponding type declarations. !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -44, +43 lines =@@ +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "package/cjs"; +- import * as mjs from "package/mjs"; +- import * as type from "package"; +- cjs; +- mjs; +- type; +- import * as cjsi from "inner/cjs"; +- import * as mjsi from "inner/mjs"; +- import * as typei from "inner"; +- cjsi; +- mjsi; +- typei; +-==== index.cjs (0 errors) ==== ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. ++ import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. ++ import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++ import * as cjsi from "inner/cjs"; ++ import * as mjsi from "inner/mjs"; ++ import * as typei from "inner"; ++ cjsi; ++ mjsi; ++ typei; ++==== index.cjs (3 errors) ==== + // cjs format file + import * as cjs from "package/cjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/cjs' or its corresponding type declarations. + import * as mjs from "package/mjs"; ++ ~~~~~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package/mjs' or its corresponding type declarations. + import * as type from "package"; ++ ~~~~~~~~~ ++!!! error TS2307: Cannot find module 'package' or its corresponding type declarations. + cjs; + mjs; + type; +@@= skipped -44, +70 lines =@@ cjsi; mjsi; typei; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types.diff index cd1be96c79..9090c96128 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageExports(module=nodenext).types.diff @@ -1,6 +1,33 @@ --- old.nodeModulesAllowJsPackageExports(module=nodenext).types +++ new.nodeModulesAllowJsPackageExports(module=nodenext).types -@@= skipped -23, +23 lines =@@ +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -9,7 +36,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -18,7 +45,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.mjs === + // esm format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -27,7 +81,7 @@ import * as typei from "inner"; >typei : typeof typei -@@= skipped -9, +9 lines =@@ +@@= skipped -30, +30 lines =@@ >cjsi : typeof cjsi mjsi; @@ -36,7 +90,34 @@ typei; >typei : typeof typei -@@= skipped -29, +29 lines =@@ +@@= skipped -8, +8 lines =@@ + === index.cjs === + // cjs format file + import * as cjs from "package/cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "package/mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "package"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + import * as cjsi from "inner/cjs"; >cjsi : typeof cjsi import * as mjsi from "inner/mjs"; @@ -84,7 +165,7 @@ === node_modules/inner/index.d.mts === // esm format file -@@= skipped -40, +40 lines =@@ +@@= skipped -61, +61 lines =@@ >cjs : typeof cjs import * as mjs from "inner/mjs"; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff new file mode 100644 index 0000000000..3ec447979a --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff @@ -0,0 +1,85 @@ +--- old.nodeModulesAllowJsPackageImports(module=node16).errors.txt ++++ new.nodeModulesAllowJsPackageImports(module=node16).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. + + + !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.cjs (2 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#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("#mjs")' call instead. +- import * as type from "#type"; +- ~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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. ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.cjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + cjs; + mjs; + type; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).types.diff new file mode 100644 index 0000000000..1e99d930e1 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).types.diff @@ -0,0 +1,80 @@ +--- old.nodeModulesAllowJsPackageImports(module=node16).types ++++ new.nodeModulesAllowJsPackageImports(module=node16).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.mjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.cjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff new file mode 100644 index 0000000000..6871e9e601 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff @@ -0,0 +1,85 @@ +--- old.nodeModulesAllowJsPackageImports(module=node18).errors.txt ++++ new.nodeModulesAllowJsPackageImports(module=node18).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-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. +-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. ++index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. + + + !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.cjs (2 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#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("#mjs")' call instead. +- import * as type from "#type"; +- ~~~~~~~ +-!!! error TS1479: The current file is a CommonJS module whose 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. ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.cjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + cjs; + mjs; + type; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).types.diff new file mode 100644 index 0000000000..9296719a24 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).types.diff @@ -0,0 +1,80 @@ +--- old.nodeModulesAllowJsPackageImports(module=node18).types ++++ new.nodeModulesAllowJsPackageImports(module=node18).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.mjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.cjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff new file mode 100644 index 0000000000..b544ab3250 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff @@ -0,0 +1,79 @@ +--- old.nodeModulesAllowJsPackageImports(module=nodenext).errors.txt ++++ new.nodeModulesAllowJsPackageImports(module=nodenext).errors.txt +@@= skipped -0, +0 lines =@@ + error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ++index.cjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.cjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.cjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.js(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.js(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.js(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. ++index.mjs(2,22): error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++index.mjs(3,22): error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++index.mjs(4,23): error TS2307: Cannot find module '#type' or its corresponding type declarations. + + + !!! error TS2210: The project root is ambiguous, but is required to resolve import map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== index.js (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.mjs (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; +- cjs; +- mjs; +- type; +-==== index.cjs (0 errors) ==== +- // esm format file +- import * as cjs from "#cjs"; +- import * as mjs from "#mjs"; +- import * as type from "#type"; ++==== index.js (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.mjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. ++ cjs; ++ mjs; ++ type; ++==== index.cjs (3 errors) ==== ++ // esm format file ++ import * as cjs from "#cjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#cjs' or its corresponding type declarations. ++ import * as mjs from "#mjs"; ++ ~~~~~~ ++!!! error TS2307: Cannot find module '#mjs' or its corresponding type declarations. ++ import * as type from "#type"; ++ ~~~~~~~ ++!!! error TS2307: Cannot find module '#type' or its corresponding type declarations. + cjs; + mjs; + type; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types.diff new file mode 100644 index 0000000000..eceff52ad5 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).types.diff @@ -0,0 +1,80 @@ +--- old.nodeModulesAllowJsPackageImports(module=nodenext).types ++++ new.nodeModulesAllowJsPackageImports(module=nodenext).types +@@= skipped -2, +2 lines =@@ + === index.js === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.mjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any + + === index.cjs === + // esm format file + import * as cjs from "#cjs"; +->cjs : typeof cjs ++>cjs : any + + import * as mjs from "#mjs"; +->mjs : typeof mjs ++>mjs : any + + import * as type from "#type"; +->type : typeof type ++>type : any + + cjs; +->cjs : typeof cjs ++>cjs : any + + mjs; +->mjs : typeof mjs ++>mjs : any + + type; +->type : typeof type ++>type : any From 7f94fbc4c388486cf0f18063f1b52064616abc31 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:25:33 -0700 Subject: [PATCH 15/16] Fix typo --- internal/module/resolver.go | 2 +- ...nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt | 2 -- ...extPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff | 2 -- ...ckageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt | 2 -- ...SelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff | 2 -- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 8d92047326..15be7e69c7 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -772,7 +772,7 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string if r.compilerOptions.RootDir != "" { // A `rootDir` compiler option strongly indicates the root location rootDir = r.compilerOptions.RootDir - } else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath == "" { + } else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "" { // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations rootDir = r.compilerOptions.ConfigFilePath } else { diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt index 2915352d08..94d98a813d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt @@ -1,8 +1,6 @@ -error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== tsconfig.json (0 errors) ==== { "compilerOptions": { diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff index 2ff246db57..7d11a0b922 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff @@ -2,11 +2,9 @@ +++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt @@= skipped -0, +0 lines =@@ - -+error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + -+!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== tsconfig.json (0 errors) ==== + { + "compilerOptions": { diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt index 9b55776457..78b1581d01 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt @@ -1,8 +1,6 @@ -error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. ==== tsconfig.json (0 errors) ==== { "compilerOptions": { diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff index 7365ad807a..4b52c81320 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff @@ -2,11 +2,9 @@ +++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt @@= skipped -0, +0 lines =@@ - -+error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. + + -+!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +==== tsconfig.json (0 errors) ==== + { + "compilerOptions": { From 2b5d3619a24b5b424a2370bd2e84a922bb6882fa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 2 Jul 2025 14:29:21 -0700 Subject: [PATCH 16/16] Simplify --- internal/module/resolver.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 15be7e69c7..6071d8535a 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -776,24 +776,16 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations rootDir = r.compilerOptions.ConfigFilePath } else { - var diagnostic *ast.Diagnostic - if isImports { - diagnostic = ast.NewDiagnostic( - nil, - core.TextRange{}, + diagnostic := ast.NewDiagnostic( + nil, + core.TextRange{}, + core.IfElse(isImports, diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, - core.IfElse(entry == "", ".", entry), // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird - packagePath, - ) - } else { - diagnostic = ast.NewDiagnostic( - nil, - core.TextRange{}, diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, - core.IfElse(entry == "", ".", entry), - packagePath, - ) - } + ), + core.IfElse(entry == "", ".", entry), // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird + packagePath, + ) r.diagnostics = append(r.diagnostics, diagnostic) return unresolved() }