diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 708307c455..431eb7b04a 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,7 @@ func processAllProgramFiles( resolvedModules[path] = task.resolutionsInFile typeResolutionsInFile[path] = task.typeResolutionsInFile sourceFileMetaDatas[path] = task.metadata + if task.jsxRuntimeImportSpecifier != nil { if jsxRuntimeImportSpecifiers == nil { jsxRuntimeImportSpecifiers = make(map[tspath.Path]*jsxRuntimeImportSpecifier, totalFileCount) @@ -183,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 }) @@ -201,6 +224,7 @@ func processAllProgramFiles( unsupportedExtensions: unsupportedExtensions, sourceFilesFoundSearchingNodeModules: sourceFilesFoundSearchingNodeModules, libFiles: libFileSet, + fileLoadDiagnostics: fileLoadDiagnostics, } } @@ -372,6 +396,7 @@ 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 + if resolved.IsResolved() { t.addSubTask(resolvedRef{ fileName: resolved.ResolvedFileName, diff --git a/internal/compiler/parsetask.go b/internal/compiler/parsetask.go index ebb6fdcce3..9d7045bfc4 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 fa2ac6e908..25607fdb62 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -330,6 +330,11 @@ func (p *Program) GetSuggestionDiagnostics(ctx context.Context, sourceFile *ast. return p.getDiagnosticsHelper(ctx, sourceFile, true /*ensureBound*/, true /*ensureChecked*/, p.getSuggestionDiagnosticsForFile) } +func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic { + // !!! + 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..c2fefa12bd 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.GetProgramDiagnostics()...) if len(allDiagnostics) == configFileParsingDiagnosticsLength { // Options diagnostics include global diagnostics (even though we collect them separately), diff --git a/internal/module/resolver.go b/internal/module/resolver.go index d054c1846d..6071d8535a 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -34,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 { @@ -54,7 +58,7 @@ type resolutionState struct { resolvedPackageDirectory bool failedLookupLocations []string affectingLocations []string - diagnostics []ast.Diagnostic + diagnostics []*ast.Diagnostic } func newResolutionState( @@ -748,10 +752,104 @@ 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 + 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(), + }, + )) { + + // 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 { + 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, + 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), // 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() + } + + 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 + } + } + } + } + } + } + } + } return continueSearching() } +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") { @@ -1377,7 +1475,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() 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/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 { diff --git a/internal/testutil/harnessutil/harnessutil.go b/internal/testutil/harnessutil/harnessutil.go index 9c2c324ef7..043bfa27cb 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.GetProgramDiagnostics()...) diagnostics = append(diagnostics, program.GetSyntacticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, nil)...) diagnostics = append(diagnostics, program.GetGlobalDiagnostics(ctx)...) 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/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 index 67aff83133..d26c2693e1 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.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.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. ==== package.json (0 errors) ==== { "name": "@this/package", diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff index cc3c7951f6..e4db2adb78 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDir.errors.txt.diff @@ -1,17 +1,12 @@ --- 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. + 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 =@@ + + + !!! 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" } } diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt index c717ff4c92..30c150c783 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.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.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. ==== package.json (0 errors) ==== { "name": "@this/package", diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff index 6d0833fe41..65d0b7ee4b 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDir.errors.txt.diff @@ -1,17 +1,12 @@ --- 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. + 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 =@@ + + + !!! 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 =@@ } } } diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt index d253a0fa23..c69d272c9d 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.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. 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/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff index 331017e8ed..ab5efeb973 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff @@ -1,17 +1,12 @@ --- 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. + 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 =@@ + + + !!! 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"; 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/nodeAllowJsPackageSelfName(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt index 8192673cec..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,19 +1,27 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 8192673cec..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,19 +1,27 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 new file mode 100644 index 0000000000..4454c8d1b0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt @@ -0,0 +1,32 @@ +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 (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) ==== + { + "name": "package", + "private": true, + "type": "module", + "exports": "./index.js" + } \ No newline at end of file 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/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..b5d4bfc7cf 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types +++ b/testdata/baselines/reference/submodule/conformance/nodeAllowJsPackageSelfName2.types @@ -9,7 +9,3 @@ export const foo = 1; import { foo } from "js-self-name-import/foo.js"; >foo : 1 -=== /types/src/foo.d.ts === -export const foo: 1; ->foo : 1 - 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..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,12 +1,27 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 @@ 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; @@ -34,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 98529e67ed..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,12 +1,27 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 @@ 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; @@ -34,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 new file mode 100644 index 0000000000..0e7496180a --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsConditionalPackageExports(module=nodenext).errors.txt @@ -0,0 +1,153 @@ +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 (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; + 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/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 a443d0e020..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,15 +1,30 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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; @@ -19,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; @@ -33,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 a443d0e020..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,15 +1,30 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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; @@ -19,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; @@ -33,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 new file mode 100644 index 0000000000..4297bbb071 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageExports(module=nodenext).errors.txt @@ -0,0 +1,118 @@ +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 (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; + 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/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 cda549c5c6..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,32 +1,55 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 cda549c5c6..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,32 +1,55 @@ -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.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. -==== index.js (0 errors) ==== +!!! 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 (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 new file mode 100644 index 0000000000..6aecf9a590 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt @@ -0,0 +1,67 @@ +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 (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; +==== 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/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 c68a2e33ac..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,12 +1,27 @@ -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.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. -==== index.ts (0 errors) ==== +!!! 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 (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 @@ 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; @@ -34,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 e9942e7cee..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 @@ -1,20 +1,117 @@ --- 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. - 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.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 ++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) ==== +- // 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"; -@@= skipped -57, +53 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 c68a2e33ac..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,12 +1,27 @@ -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.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. -==== index.ts (0 errors) ==== +!!! 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 (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 @@ 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; @@ -34,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 31501b0fc2..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 @@ -1,20 +1,117 @@ --- 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. - 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.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 ++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) ==== +- // 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"; -@@= skipped -57, +53 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 new file mode 100644 index 0000000000..35c27166e7 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesConditionalPackageExports(module=nodenext).errors.txt @@ -0,0 +1,153 @@ +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 (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; + 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..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 @@ -1,12 +1,21 @@ --- 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.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) ==== - // esm format file - import * as cjs from "package/cjs"; @@ -40,97 +49,87 @@ - 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; ++==== 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; -==== 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/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 f82891bb16..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,6 +1,14 @@ -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.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. @@ -8,11 +16,18 @@ 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. -==== index.ts (0 errors) ==== +!!! 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 (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; @@ -22,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; @@ -36,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 index 4add3e1812..73553cbdb4 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node16).errors.txt.diff @@ -1,15 +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. + 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. -@@= skipped -8, +7 lines =@@ - node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. ++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"; \ No newline at end of file + !!! 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 f82891bb16..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,6 +1,14 @@ -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.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. @@ -8,11 +16,18 @@ 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. -==== index.ts (0 errors) ==== +!!! 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 (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; @@ -22,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; @@ -36,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 index fe5127f4e7..783da0f98a 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=node18).errors.txt.diff @@ -1,15 +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. + 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. -@@= skipped -8, +7 lines =@@ - node_modules/inner/index.d.ts(5,1): error TS1036: Statements are not allowed in ambient contexts. ++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"; \ No newline at end of file + !!! 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 ee951d981a..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,13 +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. -==== index.ts (0 errors) ==== +!!! 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 (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; @@ -17,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; @@ -31,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 index aacb51049e..3aafdb3bf0 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesDeclarationEmitWithPackageExports(module=nodenext).errors.txt.diff @@ -1,13 +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. + 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"; \ No newline at end of file + !!! 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 ce2e504ca9..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,15 +1,30 @@ -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.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. -==== index.ts (0 errors) ==== +!!! 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 (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; @@ -19,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; @@ -33,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 e5ce7ee5df..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,20 +1,111 @@ --- 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. - 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.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. --!!! 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 + !!! 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"; -@@= skipped -55, +52 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 ce2e504ca9..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,15 +1,30 @@ -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.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. -==== index.ts (0 errors) ==== +!!! 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 (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; @@ -19,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; @@ -33,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 549e862520..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,20 +1,111 @@ --- 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. - 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.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. --!!! 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 + !!! 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"; -@@= skipped -55, +52 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 new file mode 100644 index 0000000000..965adec9a2 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesPackageExports(module=nodenext).errors.txt @@ -0,0 +1,118 @@ +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 (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; + 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..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 @@ -1,11 +1,20 @@ --- 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.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) ==== - // esm format file - import * as cjs from "package/cjs"; @@ -35,64 +44,70 @@ - 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; ++==== 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; -==== 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/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 index dad6391b99..0421736050 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node16).errors.txt.diff @@ -1,11 +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. + 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) ==== + !!! 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"; \ No newline at end of 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 index 4c45ede330..636c794545 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=node18).errors.txt.diff @@ -1,11 +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. + 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) ==== + !!! 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"; \ No newline at end of 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 index ed0557e4a3..04b57f5a08 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName(module=nodenext).errors.txt.diff @@ -1,10 +1,13 @@ --- 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. + 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"; @@ -16,12 +19,23 @@ -==== 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 ++==== 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/nodeAllowJsPackageSelfName2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff deleted file mode 100644 index fc132a3084..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeAllowJsPackageSelfName2.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.nodeAllowJsPackageSelfName2.types -+++ new.nodeAllowJsPackageSelfName2.types -@@= skipped -8, +8 lines =@@ - import { foo } from "js-self-name-import/foo.js"; - >foo : 1 - -+=== /types/src/foo.d.ts === -+export const foo: 1; -+>foo : 1 -+ \ 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..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 @@ -1,20 +1,117 @@ --- 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. - 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.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 ++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) ==== +- // 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"; -@@= skipped -57, +53 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 2de1a10500..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 @@ -1,20 +1,117 @@ --- 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. - 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.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 ++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) ==== +- // 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"; -@@= skipped -57, +53 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 0205855c12..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 @@ -1,12 +1,21 @@ --- 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.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) ==== - // esm format file - import * as cjs from "package/cjs"; @@ -40,97 +49,87 @@ - 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; ++==== 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; -==== 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/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 53583e22aa..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,20 +1,111 @@ --- 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. - 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.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. --!!! 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 + !!! 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"; -@@= skipped -55, +52 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 d606aad7ef..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,20 +1,111 @@ --- 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. - 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.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. --!!! 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 + !!! 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"; -@@= skipped -55, +52 lines =@@ ++ ~~~~~~~~~~~~~ ++!!! 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 440a91b5c4..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 @@ -1,11 +1,20 @@ --- 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.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) ==== - // esm format file - import * as cjs from "package/cjs"; @@ -35,64 +44,70 @@ - 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; ++==== 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; -==== 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/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 index 1d2cbe9b35..3ec447979a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node16).errors.txt.diff @@ -1,12 +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. + 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"; \ No newline at end of file + !!! 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 index 110b3d4008..6871e9e601 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=node18).errors.txt.diff @@ -1,12 +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. + 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"; \ No newline at end of file + !!! 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 index 493bdc69ed..b544ab3250 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesAllowJsPackageImports(module=nodenext).errors.txt.diff @@ -1,10 +1,19 @@ --- 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. + 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"; @@ -26,19 +35,45 @@ - 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 ++==== 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 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;