diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 35c4d96ace..5d07ec3d93 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -14871,7 +14871,7 @@ func (c *Checker) resolveExternalModule(location *ast.Node, moduleReference stri return c.getMergedSymbol(sourceFile.Symbol) } if errorNode != nil && moduleNotFoundError != nil && !isSideEffectImport(errorNode) { - c.error(errorNode, diagnostics.File_0_is_not_a_module, sourceFile.FileName()) + c.error(errorNode, diagnostics.File_0_is_not_a_module, resolvedModule.ResolvedFileName) } return nil } diff --git a/internal/compiler/fileloader.go b/internal/compiler/fileloader.go index 6fdbf008ea..2d9e722bed 100644 --- a/internal/compiler/fileloader.go +++ b/internal/compiler/fileloader.go @@ -68,7 +68,11 @@ type processedFiles struct { // if file was included using source file and its output is actually part of program // this contains mapping from output to source file outputFileToProjectReferenceSource map[tspath.Path]string - finishedProcessing bool + // Key is a file path. Value is the list of files that redirect to it (same package, different install location) + redirectTargetsMap map[tspath.Path][]string + // Any paths involved in deduplication, including canonical paths and redirected paths + deduplicatedPaths collections.Set[tspath.Path] + finishedProcessing bool } type jsxRuntimeImportSpecifier struct { @@ -189,6 +193,7 @@ func (p *fileLoader) resolveAutomaticTypeDirectives(containingFileName string) ( kind: fileIncludeKindAutomaticTypeDirectiveFile, data: &automaticTypeDirectiveFileData{name, resolved.PackageId}, }, + packageId: resolved.PackageId, }) } } @@ -359,6 +364,7 @@ func (p *fileLoader) resolveTypeReferenceDirectives(t *parseTask) { increaseDepth: resolved.IsExternalLibraryImport, elideOnDepth: false, includeReason: includeReason, + packageId: resolved.PackageId, }, nil) } else { t.processingDiagnostics = append(t.processingDiagnostics, &processingDiagnostic{ @@ -465,6 +471,7 @@ func (p *fileLoader) resolveImportsAndModuleAugmentations(t *parseTask) { synthetic: core.IfElse(importIndex < 0, entry, nil), }, }, + packageId: resolvedModule.PackageId, }, nil) } } diff --git a/internal/compiler/filesparser.go b/internal/compiler/filesparser.go index 307e6ccd65..4e963bd7d3 100644 --- a/internal/compiler/filesparser.go +++ b/internal/compiler/filesparser.go @@ -25,6 +25,7 @@ type parseTask struct { startedSubTasks bool isForAutomaticTypeDirective bool includeReason *FileIncludeReason + packageId module.PackageId metadata ast.SourceFileMetaData resolutionsInFile module.ModeAwareCache[*module.ResolvedModule] @@ -164,6 +165,7 @@ type resolvedRef struct { increaseDepth bool elideOnDepth bool includeReason *FileIncludeReason + packageId module.PackageId } func (t *parseTask) addSubTask(ref resolvedRef, libFile *LibFile) { @@ -174,6 +176,7 @@ func (t *parseTask) addSubTask(ref resolvedRef, libFile *LibFile) { increaseDepth: ref.increaseDepth, elideOnDepth: ref.elideOnDepth, includeReason: ref.includeReason, + packageId: ref.packageId, } t.subTasks = append(t.subTasks, subTask) } @@ -190,6 +193,7 @@ type parseTaskData struct { mu sync.Mutex lowestDepth int startedSubTasks bool + packageId module.PackageId } func (w *filesParser) parse(loader *fileLoader, tasks []*parseTask) { @@ -220,6 +224,11 @@ func (w *filesParser) start(loader *fileLoader, tasks []*parseTask, depth int) { } } + // Propagate packageId to data if we have one and data doesn't yet + if data.packageId.Name == "" && task.packageId.Name != "" { + data.packageId = task.packageId + } + currentDepth := core.IfElse(task.increaseDepth, depth+1, depth) if currentDepth < data.lowestDepth { // If we're seeing this task at a lower depth than before, @@ -283,6 +292,14 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { var sourceFilesFoundSearchingNodeModules collections.Set[tspath.Path] libFilesMap := make(map[tspath.Path]*LibFile, libFileCount) + var redirectTargetsMap map[tspath.Path][]string + var deduplicatedPaths collections.Set[tspath.Path] + var packageIdToCanonicalPath map[module.PackageId]tspath.Path + if !loader.opts.Config.CompilerOptions().DeduplicatePackages.IsFalse() { + redirectTargetsMap = make(map[tspath.Path][]string) + packageIdToCanonicalPath = make(map[module.PackageId]tspath.Path) + } + var collectFiles func(tasks []*parseTask, seen map[*parseTaskData]string) collectFiles = func(tasks []*parseTask, seen map[*parseTaskData]string) { for _, task := range tasks { @@ -331,8 +348,23 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { for _, trace := range task.resolutionsTrace { loader.opts.Host.Trace(trace.Message, trace.Args...) } - if subTasks := task.subTasks; len(subTasks) > 0 { - collectFiles(subTasks, seen) + + var existingCanonicalPath tspath.Path + if packageIdToCanonicalPath != nil && data.packageId.Name != "" { + if canonical, exists := packageIdToCanonicalPath[data.packageId]; exists { + redirectTargetsMap[canonical] = append(redirectTargetsMap[canonical], task.normalizedFilePath) + existingCanonicalPath = canonical + deduplicatedPaths.Add(task.path) + deduplicatedPaths.Add(canonical) + } else { + packageIdToCanonicalPath[data.packageId] = task.path + } + } + + if existingCanonicalPath == "" { + if subTasks := task.subTasks; len(subTasks) > 0 { + collectFiles(subTasks, seen) + } } // Exclude automatic type directive tasks from include reason processing, @@ -350,6 +382,10 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { continue } file := task.file + if existingCanonicalPath != "" { + file = filesByPath[existingCanonicalPath] + } + path := task.path if len(task.processingDiagnostics) > 0 { @@ -365,7 +401,7 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { if task.libFile != nil { libFiles = append(libFiles, file) libFilesMap[path] = task.libFile - } else { + } else if existingCanonicalPath == "" { files = append(files, file) } filesByPath[path] = file @@ -424,6 +460,8 @@ func (w *filesParser) getProcessedFiles(loader *fileLoader) processedFiles { missingFiles: missingFiles, includeProcessor: includeProcessor, outputFileToProjectReferenceSource: outputFileToProjectReferenceSource, + redirectTargetsMap: redirectTargetsMap, + deduplicatedPaths: deduplicatedPaths, } } diff --git a/internal/compiler/program.go b/internal/compiler/program.go index 834d842ab7..7e9b1777f4 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -116,9 +116,10 @@ func (p *Program) GetPackageJsonInfo(pkgJsonPath string) *packagejson.InfoCacheE return nil } -// GetRedirectTargets implements checker.Program. +// GetRedirectTargets returns the list of file paths that redirect to the given path. +// These are files from the same package (same name@version) installed in different locations. func (p *Program) GetRedirectTargets(path tspath.Path) []string { - return nil // !!! TODO: project references support + return p.redirectTargetsMap[path] } // gets the original file that was included in program @@ -247,6 +248,13 @@ func (p *Program) UpdateProgram(changedFilePath tspath.Path, newHost CompilerHos if !canReplaceFileInProgram(oldFile, newFile) { return NewProgram(newOpts), false } + // If this file is part of a package redirect group (same package installed in multiple + // node_modules locations), we need to rebuild the program because the redirect targets + // might need recalculation. + if p.deduplicatedPaths.Has(changedFilePath) { + // File is either a canonical file or a redirect target; either way, need full rebuild + return NewProgram(newOpts), false + } // TODO: reverify compiler options when config has changed? result := &Program{ opts: newOpts, diff --git a/internal/core/compileroptions.go b/internal/core/compileroptions.go index 6fc84c84e1..b2abf70704 100644 --- a/internal/core/compileroptions.go +++ b/internal/core/compileroptions.go @@ -36,6 +36,7 @@ type CompilerOptions struct { Declaration Tristate `json:"declaration,omitzero"` DeclarationDir string `json:"declarationDir,omitzero"` DeclarationMap Tristate `json:"declarationMap,omitzero"` + DeduplicatePackages Tristate `json:"deduplicatePackages,omitzero"` DisableSizeLimit Tristate `json:"disableSizeLimit,omitzero"` DisableSourceOfProjectReferenceRedirect Tristate `json:"disableSourceOfProjectReferenceRedirect,omitzero"` DisableSolutionSearching Tristate `json:"disableSolutionSearching,omitzero"` diff --git a/internal/diagnostics/diagnostics_generated.go b/internal/diagnostics/diagnostics_generated.go index 14c2a9b0f4..26789f741c 100644 --- a/internal/diagnostics/diagnostics_generated.go +++ b/internal/diagnostics/diagnostics_generated.go @@ -4276,6 +4276,8 @@ var Set_the_number_of_projects_to_build_concurrently = &Message{code: 100009, ca var X_all_unless_singleThreaded_is_passed = &Message{code: 100010, category: CategoryMessage, key: "all_unless_singleThreaded_is_passed_100010", text: "all, unless --singleThreaded is passed."} +var Deduplicate_packages_with_the_same_name_and_version = &Message{code: 100011, category: CategoryMessage, key: "Deduplicate_packages_with_the_same_name_and_version_100011", text: "Deduplicate packages with the same name and version."} + func keyToMessage(key Key) *Message { switch key { case "Unterminated_string_literal_1002": @@ -8552,6 +8554,8 @@ func keyToMessage(key Key) *Message { return Set_the_number_of_projects_to_build_concurrently case "all_unless_singleThreaded_is_passed_100010": return X_all_unless_singleThreaded_is_passed + case "Deduplicate_packages_with_the_same_name_and_version_100011": + return Deduplicate_packages_with_the_same_name_and_version default: return nil } diff --git a/internal/diagnostics/extraDiagnosticMessages.json b/internal/diagnostics/extraDiagnosticMessages.json index 2566d6ff53..2bd4640ff2 100644 --- a/internal/diagnostics/extraDiagnosticMessages.json +++ b/internal/diagnostics/extraDiagnosticMessages.json @@ -86,5 +86,9 @@ "Option '{0}' requires value to be greater than '{1}'.": { "category": "Error", "code": 5002 + }, + "Deduplicate packages with the same name and version.": { + "category": "Message", + "code": 100011 } } diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index 2b3d4104bb..e5e21554c4 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -231,7 +231,6 @@ TestContextuallyTypedFunctionExpressionGeneric1 TestContextualTypingOfGenericCallSignatures2 TestCrossFileQuickInfoExportedTypeDoesNotUseImportType TestDoubleUnderscoreCompletions -TestDuplicatePackageServices TestEditJsdocType TestErrorsAfterResolvingVariableDeclOfMergedVariableAndClassDecl TestExportDefaultClass diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt index 658a51bed2..ebc0a861be 100644 --- a/internal/fourslash/_scripts/manualTests.txt +++ b/internal/fourslash/_scripts/manualTests.txt @@ -2,6 +2,7 @@ completionListInClosedFunction05 completionsAtIncompleteObjectLiteralProperty completionsSelfDeclaring1 completionsWithDeprecatedTag4 +duplicatePackageServices_fileChanges navigationBarFunctionPrototype navigationBarFunctionPrototype2 navigationBarFunctionPrototype3 @@ -38,4 +39,4 @@ stringLiteralCompletionsInPositionTypedUsingRest importNameCodeFix_uriStyleNodeCoreModules1 completionsImport_filteredByPackageJson_ambient importNameCodeFixDefaultExport7 -importNameCodeFixOptionalImport0 \ No newline at end of file +importNameCodeFixOptionalImport0 diff --git a/internal/fourslash/tests/manual/duplicatePackageServices_fileChanges_test.go b/internal/fourslash/tests/manual/duplicatePackageServices_fileChanges_test.go new file mode 100644 index 0000000000..a3aed4e54a --- /dev/null +++ b/internal/fourslash/tests/manual/duplicatePackageServices_fileChanges_test.go @@ -0,0 +1,68 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDuplicatePackageServices_fileChanges(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @noImplicitReferences: true +// @Filename: /node_modules/a/index.d.ts +import X from "x"; +export function a(x: X): void; +// @Filename: /node_modules/a/node_modules/x/index.d.ts +export default class /*defAX*/X { + private x: number; +} +// @Filename: /node_modules/a/node_modules/x/package.json +{ "name": "x", "version": "1.2./*aVersionPatch*/3" } +// @Filename: /node_modules/b/index.d.ts +import X from "x"; +export const b: X; +// @Filename: /node_modules/b/node_modules/x/index.d.ts +export default class /*defBX*/X { + private x: number; +} +// @Filename: /node_modules/b/node_modules/x/package.json +{ "name": "x", "version": "1.2./*bVersionPatch*/3" } +// @Filename: /src/a.ts +import { a } from "a"; +import { b } from "b"; +a(/*error*/b);` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + + f.GoToFile(t, "/src/a.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + + testChangeAndChangeBack := func(versionPatch string, def string) { + // Insert "4" after the version patch marker, changing version from 1.2.3 to 1.2.43 + f.GoToMarker(t, versionPatch) + f.Insert(t, "4") + + // Insert a space after the definition marker to trigger a recheck + f.GoToMarker(t, def) + f.Insert(t, " ") + + // No longer have identical packageId, so we get errors. + f.VerifyErrorExistsAfterMarker(t, "error") + + // Undo the changes + f.GoToMarker(t, versionPatch) + f.DeleteAtCaret(t, 1) + f.GoToMarker(t, def) + f.DeleteAtCaret(t, 1) + + // Back to being identical. + f.GoToFile(t, "/src/a.ts") + f.VerifyNumberOfErrorsInCurrentFile(t, 0) + } + + testChangeAndChangeBack("aVersionPatch", "defAX") + testChangeAndChangeBack("bVersionPatch", "defBX") +} diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 40bcfd8aa6..211df2a39c 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -986,7 +986,7 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi } if fromDirectory := r.loadNodeModuleFromDirectoryWorker(ext, candidate, !nodeModulesDirectoryExists, packageInfo); !fromDirectory.shouldContinueSearching() { - fromDirectory.packageId = r.getPackageId(packageDirectory, packageInfo) + fromDirectory.packageId = r.getPackageId(fromDirectory.path, packageInfo) return fromDirectory } } @@ -995,12 +995,12 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi loader := func(extensions extensions, candidate string, onlyRecordFailures bool) *resolved { if rest != "" || !r.esmMode { if fromFile := r.loadModuleFromFile(extensions, candidate, onlyRecordFailures); !fromFile.shouldContinueSearching() { - fromFile.packageId = r.getPackageId(packageDirectory, packageInfo) + fromFile.packageId = r.getPackageId(fromFile.path, packageInfo) return fromFile } } if fromDirectory := r.loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, packageInfo); !fromDirectory.shouldContinueSearching() { - fromDirectory.packageId = r.getPackageId(packageDirectory, packageInfo) + fromDirectory.packageId = r.getPackageId(fromDirectory.path, packageInfo) return fromDirectory } // !!! this is ported exactly, but checking for null seems wrong? @@ -1010,7 +1010,7 @@ func (r *resolutionState) loadModuleFromSpecificNodeModulesDirectory(ext extensi // EsmMode disables index lookup in `loadNodeModuleFromDirectoryWorker` generally, however non-relative package resolutions still assume // a default `index.js` entrypoint if no `main` or `exports` are present if indexResult := r.loadModuleFromFile(extensions, tspath.CombinePaths(candidate, "index.js"), onlyRecordFailures); !indexResult.shouldContinueSearching() { - indexResult.packageId = r.getPackageId(packageDirectory, packageInfo) + indexResult.packageId = r.getPackageId(indexResult.path, packageInfo) return indexResult } } diff --git a/internal/tsoptions/declscompiler.go b/internal/tsoptions/declscompiler.go index 1550e1680d..ac16be0b7b 100644 --- a/internal/tsoptions/declscompiler.go +++ b/internal/tsoptions/declscompiler.go @@ -185,6 +185,14 @@ var commonOptionsWithBuild = []*CommandLineOption{ DefaultValueDescription: false, // Not setting affectsSemanticDiagnostics or affectsBuildInfo because we dont want all diagnostics to go away, its handled in builder }, + { + Name: "deduplicatePackages", + Kind: CommandLineOptionTypeBoolean, + Category: diagnostics.Type_Checking, + Description: diagnostics.Deduplicate_packages_with_the_same_name_and_version, + DefaultValueDescription: true, + AffectsProgramStructure: true, + }, { Name: "noEmit", Kind: CommandLineOptionTypeBoolean, diff --git a/internal/tsoptions/parsinghelpers.go b/internal/tsoptions/parsinghelpers.go index 4a3763168a..a631b28d1e 100644 --- a/internal/tsoptions/parsinghelpers.go +++ b/internal/tsoptions/parsinghelpers.go @@ -217,6 +217,8 @@ func parseCompilerOptions(key string, value any, allOptions *core.CompilerOption allOptions.Composite = ParseTristate(value) case "declarationDir": allOptions.DeclarationDir = ParseString(value) + case "deduplicatePackages": + allOptions.DeduplicatePackages = ParseTristate(value) case "diagnostics": allOptions.Diagnostics = ParseTristate(value) case "disableSizeLimit": diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).errors.txt b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).errors.txt new file mode 100644 index 0000000000..4e9b3720b6 --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).errors.txt @@ -0,0 +1,66 @@ +/node_modules/b/index.d.ts(1,15): error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. +/node_modules/b/node_modules/x/index.d.ts(1,1): error TS1434: Unexpected keyword or identifier. +/node_modules/b/node_modules/x/index.d.ts(1,1): error TS2304: Cannot find name 'content'. +/node_modules/b/node_modules/x/index.d.ts(1,9): error TS1434: Unexpected keyword or identifier. +/node_modules/b/node_modules/x/index.d.ts(1,9): error TS2304: Cannot find name 'not'. +/node_modules/b/node_modules/x/index.d.ts(1,13): error TS2304: Cannot find name 'parsed'. +/src/a.ts(5,3): error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. + Types have separate declarations of a private property 'x'. + + +==== /src/a.ts (1 errors) ==== + import { a } from "a"; + import { b } from "b"; + import { c } from "c"; + a(b); // Works + a(c); // Error, these are from different versions of the library. + ~ +!!! error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. +!!! error TS2345: Types have separate declarations of a private property 'x'. + +==== /node_modules/a/index.d.ts (0 errors) ==== + import X from "x"; + export function a(x: X): void; + +==== /node_modules/a/node_modules/x/index.d.ts (0 errors) ==== + export default class X { + private x: number; + } + +==== /node_modules/a/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.3" } + +==== /node_modules/b/index.d.ts (1 errors) ==== + import X from "x"; + ~~~ +!!! error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. + export const b: X; + +==== /node_modules/b/node_modules/x/index.d.ts (5 errors) ==== + content not parsed + ~~~~~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~~~~~ +!!! error TS2304: Cannot find name 'content'. + ~~~ +!!! error TS1434: Unexpected keyword or identifier. + ~~~ +!!! error TS2304: Cannot find name 'not'. + ~~~~~~ +!!! error TS2304: Cannot find name 'parsed'. + +==== /node_modules/b/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.3" } + +==== /node_modules/c/index.d.ts (0 errors) ==== + import X from "x"; + export const c: X; + +==== /node_modules/c/node_modules/x/index.d.ts (0 errors) ==== + export default class X { + private x: number; + } + +==== /node_modules/c/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.4" } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).js b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).js new file mode 100644 index 0000000000..4f0edc0612 --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +//// [index.d.ts] +import X from "x"; +export function a(x: X): void; + +//// [index.d.ts] +export default class X { + private x: number; +} + +//// [package.json] +{ "name": "x", "version": "1.2.3" } + +//// [index.d.ts] +import X from "x"; +export const b: X; + +//// [index.d.ts] +content not parsed + +//// [package.json] +{ "name": "x", "version": "1.2.3" } + +//// [index.d.ts] +import X from "x"; +export const c: X; + +//// [index.d.ts] +export default class X { + private x: number; +} + +//// [package.json] +{ "name": "x", "version": "1.2.4" } + +//// [a.ts] +import { a } from "a"; +import { b } from "b"; +import { c } from "c"; +a(b); // Works +a(c); // Error, these are from different versions of the library. + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const a_1 = require("a"); +const b_1 = require("b"); +const c_1 = require("c"); +(0, a_1.a)(b_1.b); // Works +(0, a_1.a)(c_1.c); // Error, these are from different versions of the library. diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).symbols b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).symbols new file mode 100644 index 0000000000..e339c9b460 --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).symbols @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +=== /src/a.ts === +import { a } from "a"; +>a : Symbol(a, Decl(a.ts, 0, 8)) + +import { b } from "b"; +>b : Symbol(b, Decl(a.ts, 1, 8)) + +import { c } from "c"; +>c : Symbol(c, Decl(a.ts, 2, 8)) + +a(b); // Works +>a : Symbol(a, Decl(a.ts, 0, 8)) +>b : Symbol(b, Decl(a.ts, 1, 8)) + +a(c); // Error, these are from different versions of the library. +>a : Symbol(a, Decl(a.ts, 0, 8)) +>c : Symbol(c, Decl(a.ts, 2, 8)) + +=== /node_modules/a/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export function a(x: X): void; +>a : Symbol(a, Decl(index.d.ts, 0, 18)) +>x : Symbol(x, Decl(index.d.ts, 1, 18)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/a/node_modules/x/index.d.ts === +export default class X { +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + + private x: number; +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) +} + +=== /node_modules/b/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export const b: X; +>b : Symbol(b, Decl(index.d.ts, 1, 12)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/b/node_modules/x/index.d.ts === + +content not parsed + +=== /node_modules/c/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export const c: X; +>c : Symbol(c, Decl(index.d.ts, 1, 12)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/c/node_modules/x/index.d.ts === +export default class X { +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + + private x: number; +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) +} + diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).types b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).types new file mode 100644 index 0000000000..8d0db6b706 --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=false).types @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +=== /src/a.ts === +import { a } from "a"; +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void + +import { b } from "b"; +>b : X + +import { c } from "c"; +>c : import("/node_modules/c/node_modules/x/index").default + +a(b); // Works +>a(b) : void +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>b : X + +a(c); // Error, these are from different versions of the library. +>a(c) : void +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>c : import("/node_modules/c/node_modules/x/index").default + +=== /node_modules/a/index.d.ts === +import X from "x"; +>X : typeof X + +export function a(x: X): void; +>a : (x: X) => void +>x : X + +=== /node_modules/a/node_modules/x/index.d.ts === +export default class X { +>X : X + + private x: number; +>x : number +} + +=== /node_modules/b/index.d.ts === +import X from "x"; +>X : any + +export const b: X; +>b : X + +=== /node_modules/b/node_modules/x/index.d.ts === +content not parsed +>content : any +>not : any +>parsed : any + +=== /node_modules/c/index.d.ts === +import X from "x"; +>X : typeof X + +export const c: X; +>c : X + +=== /node_modules/c/node_modules/x/index.d.ts === +export default class X { +>X : X + + private x: number; +>x : number +} + diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).errors.txt b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).errors.txt new file mode 100644 index 0000000000..99d5a3f29c --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).errors.txt @@ -0,0 +1,48 @@ +/src/a.ts(5,3): error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. + Types have separate declarations of a private property 'x'. + + +==== /src/a.ts (1 errors) ==== + import { a } from "a"; + import { b } from "b"; + import { c } from "c"; + a(b); // Works + a(c); // Error, these are from different versions of the library. + ~ +!!! error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. +!!! error TS2345: Types have separate declarations of a private property 'x'. + +==== /node_modules/a/index.d.ts (0 errors) ==== + import X from "x"; + export function a(x: X): void; + +==== /node_modules/a/node_modules/x/index.d.ts (0 errors) ==== + export default class X { + private x: number; + } + +==== /node_modules/a/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.3" } + +==== /node_modules/b/index.d.ts (0 errors) ==== + import X from "x"; + export const b: X; + +==== /node_modules/b/node_modules/x/index.d.ts (0 errors) ==== + content not parsed + +==== /node_modules/b/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.3" } + +==== /node_modules/c/index.d.ts (0 errors) ==== + import X from "x"; + export const c: X; + +==== /node_modules/c/node_modules/x/index.d.ts (0 errors) ==== + export default class X { + private x: number; + } + +==== /node_modules/c/node_modules/x/package.json (0 errors) ==== + { "name": "x", "version": "1.2.4" } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).js b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).js new file mode 100644 index 0000000000..4f0edc0612 --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).js @@ -0,0 +1,52 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +//// [index.d.ts] +import X from "x"; +export function a(x: X): void; + +//// [index.d.ts] +export default class X { + private x: number; +} + +//// [package.json] +{ "name": "x", "version": "1.2.3" } + +//// [index.d.ts] +import X from "x"; +export const b: X; + +//// [index.d.ts] +content not parsed + +//// [package.json] +{ "name": "x", "version": "1.2.3" } + +//// [index.d.ts] +import X from "x"; +export const c: X; + +//// [index.d.ts] +export default class X { + private x: number; +} + +//// [package.json] +{ "name": "x", "version": "1.2.4" } + +//// [a.ts] +import { a } from "a"; +import { b } from "b"; +import { c } from "c"; +a(b); // Works +a(c); // Error, these are from different versions of the library. + + +//// [a.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const a_1 = require("a"); +const b_1 = require("b"); +const c_1 = require("c"); +(0, a_1.a)(b_1.b); // Works +(0, a_1.a)(c_1.c); // Error, these are from different versions of the library. diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).symbols b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).symbols new file mode 100644 index 0000000000..6b82e45fce --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).symbols @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +=== /src/a.ts === +import { a } from "a"; +>a : Symbol(a, Decl(a.ts, 0, 8)) + +import { b } from "b"; +>b : Symbol(b, Decl(a.ts, 1, 8)) + +import { c } from "c"; +>c : Symbol(c, Decl(a.ts, 2, 8)) + +a(b); // Works +>a : Symbol(a, Decl(a.ts, 0, 8)) +>b : Symbol(b, Decl(a.ts, 1, 8)) + +a(c); // Error, these are from different versions of the library. +>a : Symbol(a, Decl(a.ts, 0, 8)) +>c : Symbol(c, Decl(a.ts, 2, 8)) + +=== /node_modules/a/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export function a(x: X): void; +>a : Symbol(a, Decl(index.d.ts, 0, 18)) +>x : Symbol(x, Decl(index.d.ts, 1, 18)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/a/node_modules/x/index.d.ts === +export default class X { +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + + private x: number; +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) +} + +=== /node_modules/b/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export const b: X; +>b : Symbol(b, Decl(index.d.ts, 1, 12)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/b/node_modules/x/index.d.ts === +content not parsed +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) + +=== /node_modules/c/index.d.ts === +import X from "x"; +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +export const c: X; +>c : Symbol(c, Decl(index.d.ts, 1, 12)) +>X : Symbol(X, Decl(index.d.ts, 0, 6)) + +=== /node_modules/c/node_modules/x/index.d.ts === +export default class X { +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + + private x: number; +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) +} + diff --git a/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).types b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).types new file mode 100644 index 0000000000..35169543ee --- /dev/null +++ b/testdata/baselines/reference/compiler/deduplicatePackages(deduplicatepackages=true).types @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/deduplicatePackages.ts] //// + +=== /src/a.ts === +import { a } from "a"; +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void + +import { b } from "b"; +>b : import("/node_modules/a/node_modules/x/index").default + +import { c } from "c"; +>c : import("/node_modules/c/node_modules/x/index").default + +a(b); // Works +>a(b) : void +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>b : import("/node_modules/a/node_modules/x/index").default + +a(c); // Error, these are from different versions of the library. +>a(c) : void +>a : (x: import("/node_modules/a/node_modules/x/index").default) => void +>c : import("/node_modules/c/node_modules/x/index").default + +=== /node_modules/a/index.d.ts === +import X from "x"; +>X : typeof X + +export function a(x: X): void; +>a : (x: X) => void +>x : X + +=== /node_modules/a/node_modules/x/index.d.ts === +export default class X { +>X : X + + private x: number; +>x : number +} + +=== /node_modules/b/index.d.ts === +import X from "x"; +>X : typeof X + +export const b: X; +>b : X + +=== /node_modules/b/node_modules/x/index.d.ts === +content not parsed +>X : X + +>x : number + +=== /node_modules/c/index.d.ts === +import X from "x"; +>X : typeof X + +export const c: X; +>c : X + +=== /node_modules/c/node_modules/x/index.d.ts === +export default class X { +>X : X + + private x: number; +>x : number +} + diff --git a/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.js b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.js new file mode 100644 index 0000000000..574b3c2051 --- /dev/null +++ b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.js @@ -0,0 +1,63 @@ +//// [tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts] //// + +//// [package.json] +{ "name": "foo", "version": "1.0.0" } + +//// [index.d.ts] +import "globals"; +export declare function useFoo(): typeof myGlobal; + +//// [package.json] +{ "name": "globals", "version": "1.0.0" } + +//// [index.d.ts] +declare var myGlobal: string; + +//// [package.json] +{ "name": "foo", "version": "1.0.0" } + +//// [index.d.ts] +import "globals"; +export declare function useFoo(): typeof myGlobal; + +//// [package.json] +{ "name": "globals", "version": "2.0.0" } + +//// [index.d.ts] +declare var myGlobal: number; + +//// [package.json] +{ "name": "bar", "version": "1.0.0" } + +//// [index.d.ts] +import { useFoo } from "foo"; +export declare function useBar(): ReturnType; + +//// [package.json] +{ "name": "baz", "version": "1.0.0" } + +//// [index.d.ts] +import { useFoo } from "foo"; +export declare function useBaz(): ReturnType; + + + + +//// [index.ts] +import { useBar } from "bar"; +import { useBaz } from "baz"; + +const barResult = useBar(); +const bazResult = useBaz(); + +const x: string = myGlobal; + + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const bar_1 = require("bar"); +const baz_1 = require("baz"); +const barResult = (0, bar_1.useBar)(); +const bazResult = (0, baz_1.useBaz)(); +const x = myGlobal; diff --git a/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.symbols b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.symbols new file mode 100644 index 0000000000..69ea54c193 --- /dev/null +++ b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.symbols @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts] //// + +=== /src/index.ts === +import { useBar } from "bar"; +>useBar : Symbol(useBar, Decl(index.ts, 0, 8)) + +import { useBaz } from "baz"; +>useBaz : Symbol(useBaz, Decl(index.ts, 1, 8)) + +const barResult = useBar(); +>barResult : Symbol(barResult, Decl(index.ts, 3, 5)) +>useBar : Symbol(useBar, Decl(index.ts, 0, 8)) + +const bazResult = useBaz(); +>bazResult : Symbol(bazResult, Decl(index.ts, 4, 5)) +>useBaz : Symbol(useBaz, Decl(index.ts, 1, 8)) + +const x: string = myGlobal; +>x : Symbol(x, Decl(index.ts, 6, 5)) +>myGlobal : Symbol(myGlobal, Decl(index.d.ts, 0, 11)) + +=== /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/foo/index.d.ts === +import "globals"; +export declare function useFoo(): typeof myGlobal; +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 17)) +>myGlobal : Symbol(myGlobal, Decl(index.d.ts, 0, 11)) + +=== /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/globals/index.d.ts === +declare var myGlobal: string; +>myGlobal : Symbol(myGlobal, Decl(index.d.ts, 0, 11)) + +=== /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/foo/index.d.ts === +import "globals"; +export declare function useFoo(): typeof myGlobal; +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 17)) +>myGlobal : Symbol(myGlobal, Decl(index.d.ts, 0, 11)) + +=== /node_modules/.pnpm/bar@1.0.0/node_modules/bar/index.d.ts === +import { useFoo } from "foo"; +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 8)) + +export declare function useBar(): ReturnType; +>useBar : Symbol(useBar, Decl(index.d.ts, 0, 29)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 8)) + +=== /node_modules/.pnpm/baz@1.0.0/node_modules/baz/index.d.ts === +import { useFoo } from "foo"; +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 8)) + +export declare function useBaz(): ReturnType; +>useBaz : Symbol(useBaz, Decl(index.d.ts, 0, 29)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>useFoo : Symbol(useFoo, Decl(index.d.ts, 0, 8)) + + + + diff --git a/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.types b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.types new file mode 100644 index 0000000000..11ce01d5f3 --- /dev/null +++ b/testdata/baselines/reference/compiler/packageDeduplicationDuplicateGlobals.types @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts] //// + +=== /src/index.ts === +import { useBar } from "bar"; +>useBar : () => string + +import { useBaz } from "baz"; +>useBaz : () => string + +const barResult = useBar(); +>barResult : string +>useBar() : string +>useBar : () => string + +const bazResult = useBaz(); +>bazResult : string +>useBaz() : string +>useBaz : () => string + +const x: string = myGlobal; +>x : string +>myGlobal : string + +=== /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/foo/index.d.ts === +import "globals"; +export declare function useFoo(): typeof myGlobal; +>useFoo : () => string +>myGlobal : string + +=== /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/globals/index.d.ts === +declare var myGlobal: string; +>myGlobal : string + +=== /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/foo/index.d.ts === +import "globals"; +export declare function useFoo(): typeof myGlobal; +>useFoo : () => string +>myGlobal : string + +=== /node_modules/.pnpm/bar@1.0.0/node_modules/bar/index.d.ts === +import { useFoo } from "foo"; +>useFoo : () => string + +export declare function useBar(): ReturnType; +>useBar : () => string +>useFoo : () => string + +=== /node_modules/.pnpm/baz@1.0.0/node_modules/baz/index.d.ts === +import { useFoo } from "foo"; +>useFoo : () => string + +export declare function useBaz(): ReturnType; +>useBaz : () => string +>useFoo : () => string + + + + diff --git a/testdata/baselines/reference/fourslash/findAllReferences/duplicatePackageServices.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/duplicatePackageServices.baseline.jsonc new file mode 100644 index 0000000000..3ca6e48ddb --- /dev/null +++ b/testdata/baselines/reference/fourslash/findAllReferences/duplicatePackageServices.baseline.jsonc @@ -0,0 +1,45 @@ +// === findAllReferences === +// === /node_modules/a/index.d.ts === +// import [|X|]/*FIND ALL REFS*/ from "x"; +// export function a(x: [|X|]): void; + +// === /node_modules/a/node_modules/x/index.d.ts === +// export default class [|X|] { +// private x: number; +// } + +// === /node_modules/b/index.d.ts === +// import [|X|] from "x"; +// export const b: [|X|]; + + + +// === findAllReferences === +// === /node_modules/a/index.d.ts === +// import [|X|] from "x"; +// export function a(x: [|X|]): void; + +// === /node_modules/a/node_modules/x/index.d.ts === +// export default class /*FIND ALL REFS*/[|X|] { +// private x: number; +// } + +// === /node_modules/b/index.d.ts === +// import [|X|] from "x"; +// export const b: [|X|]; + + + +// === findAllReferences === +// === /node_modules/a/index.d.ts === +// import [|X|] from "x"; +// export function a(x: [|X|]): void; + +// === /node_modules/a/node_modules/x/index.d.ts === +// export default class [|X|] { +// private x: number; +// } + +// === /node_modules/b/index.d.ts === +// import [|X|]/*FIND ALL REFS*/ from "x"; +// export const b: [|X|]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types index 78a2505802..3539b7c103 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types @@ -40,6 +40,6 @@ export const a = getA(); === /p2/index.d.ts === export const a: import("typescript-fsa").A; ->a : import("/p2/node_modules/typescript-fsa/index").A +>a : import("/p1/node_modules/typescript-fsa/index").A diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types.diff new file mode 100644 index 0000000000..045997d7f1 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitForGlobalishSpecifierSymlink.types.diff @@ -0,0 +1,9 @@ +--- old.declarationEmitForGlobalishSpecifierSymlink.types ++++ new.declarationEmitForGlobalishSpecifierSymlink.types +@@= skipped -39, +39 lines =@@ + + === /p2/index.d.ts === + export const a: import("typescript-fsa").A; +->a : import("/p2/node_modules/typescript-fsa/index").A ++>a : import("/p1/node_modules/typescript-fsa/index").A + diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt index 4e9b3720b6..99d5a3f29c 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt @@ -1,9 +1,3 @@ -/node_modules/b/index.d.ts(1,15): error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. -/node_modules/b/node_modules/x/index.d.ts(1,1): error TS1434: Unexpected keyword or identifier. -/node_modules/b/node_modules/x/index.d.ts(1,1): error TS2304: Cannot find name 'content'. -/node_modules/b/node_modules/x/index.d.ts(1,9): error TS1434: Unexpected keyword or identifier. -/node_modules/b/node_modules/x/index.d.ts(1,9): error TS2304: Cannot find name 'not'. -/node_modules/b/node_modules/x/index.d.ts(1,13): error TS2304: Cannot find name 'parsed'. /src/a.ts(5,3): error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. Types have separate declarations of a private property 'x'. @@ -30,24 +24,12 @@ ==== /node_modules/a/node_modules/x/package.json (0 errors) ==== { "name": "x", "version": "1.2.3" } -==== /node_modules/b/index.d.ts (1 errors) ==== +==== /node_modules/b/index.d.ts (0 errors) ==== import X from "x"; - ~~~ -!!! error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. export const b: X; -==== /node_modules/b/node_modules/x/index.d.ts (5 errors) ==== +==== /node_modules/b/node_modules/x/index.d.ts (0 errors) ==== content not parsed - ~~~~~~~ -!!! error TS1434: Unexpected keyword or identifier. - ~~~~~~~ -!!! error TS2304: Cannot find name 'content'. - ~~~ -!!! error TS1434: Unexpected keyword or identifier. - ~~~ -!!! error TS2304: Cannot find name 'not'. - ~~~~~~ -!!! error TS2304: Cannot find name 'parsed'. ==== /node_modules/b/node_modules/x/package.json (0 errors) ==== { "name": "x", "version": "1.2.3" } diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt.diff deleted file mode 100644 index ff69e90fce..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.duplicatePackage.errors.txt -+++ new.duplicatePackage.errors.txt -@@= skipped -0, +0 lines =@@ -+/node_modules/b/index.d.ts(1,15): error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. -+/node_modules/b/node_modules/x/index.d.ts(1,1): error TS1434: Unexpected keyword or identifier. -+/node_modules/b/node_modules/x/index.d.ts(1,1): error TS2304: Cannot find name 'content'. -+/node_modules/b/node_modules/x/index.d.ts(1,9): error TS1434: Unexpected keyword or identifier. -+/node_modules/b/node_modules/x/index.d.ts(1,9): error TS2304: Cannot find name 'not'. -+/node_modules/b/node_modules/x/index.d.ts(1,13): error TS2304: Cannot find name 'parsed'. - /src/a.ts(5,3): error TS2345: Argument of type 'import("/node_modules/c/node_modules/x/index").default' is not assignable to parameter of type 'import("/node_modules/a/node_modules/x/index").default'. - Types have separate declarations of a private property 'x'. - -@@= skipped -23, +29 lines =@@ - ==== /node_modules/a/node_modules/x/package.json (0 errors) ==== - { "name": "x", "version": "1.2.3" } - --==== /node_modules/b/index.d.ts (0 errors) ==== -+==== /node_modules/b/index.d.ts (1 errors) ==== - import X from "x"; -+ ~~~ -+!!! error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. - export const b: X; - --==== /node_modules/b/node_modules/x/index.d.ts (0 errors) ==== -+==== /node_modules/b/node_modules/x/index.d.ts (5 errors) ==== - content not parsed -+ ~~~~~~~ -+!!! error TS1434: Unexpected keyword or identifier. -+ ~~~~~~~ -+!!! error TS2304: Cannot find name 'content'. -+ ~~~ -+!!! error TS1434: Unexpected keyword or identifier. -+ ~~~ -+!!! error TS2304: Cannot find name 'not'. -+ ~~~~~~ -+!!! error TS2304: Cannot find name 'parsed'. - - ==== /node_modules/b/node_modules/x/package.json (0 errors) ==== - { "name": "x", "version": "1.2.3" } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols b/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols index b5fd703b49..0872054c30 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols @@ -44,8 +44,10 @@ export const b: X; >X : Symbol(X, Decl(index.d.ts, 0, 6)) === /node_modules/b/node_modules/x/index.d.ts === - content not parsed +>X : Symbol(X, Decl(index.d.ts, 0, 0)) + +>x : Symbol(X.x, Decl(index.d.ts, 0, 24)) === /node_modules/c/index.d.ts === import X from "x"; diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols.diff deleted file mode 100644 index a7dc526dc8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.symbols.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.duplicatePackage.symbols -+++ new.duplicatePackage.symbols -@@= skipped -43, +43 lines =@@ - >X : Symbol(X, Decl(index.d.ts, 0, 6)) - - === /node_modules/b/node_modules/x/index.d.ts === --content not parsed -->X : Symbol(X, Decl(index.d.ts, 0, 0)) - -->x : Symbol(X.x, Decl(index.d.ts, 0, 24)) -+content not parsed - - === /node_modules/c/index.d.ts === - import X from "x"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage.types index 77b1ce24d1..30efd9bc9e 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage.types @@ -5,7 +5,7 @@ import { a } from "a"; >a : (x: import("/node_modules/a/node_modules/x/index").default) => void import { b } from "b"; ->b : X +>b : import("/node_modules/a/node_modules/x/index").default import { c } from "c"; >c : import("/node_modules/c/node_modules/x/index").default @@ -13,7 +13,7 @@ import { c } from "c"; a(b); // Works >a(b) : void >a : (x: import("/node_modules/a/node_modules/x/index").default) => void ->b : X +>b : import("/node_modules/a/node_modules/x/index").default a(c); // Error, these are from different versions of the library. >a(c) : void @@ -38,16 +38,16 @@ export default class X { === /node_modules/b/index.d.ts === import X from "x"; ->X : any +>X : typeof X export const b: X; >b : X === /node_modules/b/node_modules/x/index.d.ts === content not parsed ->content : any ->not : any ->parsed : any +>X : X + +>x : number === /node_modules/c/index.d.ts === import X from "x"; diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage.types.diff deleted file mode 100644 index 6dcafc5f6d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage.types.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.duplicatePackage.types -+++ new.duplicatePackage.types -@@= skipped -4, +4 lines =@@ - >a : (x: import("/node_modules/a/node_modules/x/index").default) => void - - import { b } from "b"; -->b : import("/node_modules/a/node_modules/x/index").default -+>b : X - - import { c } from "c"; - >c : import("/node_modules/c/node_modules/x/index").default -@@= skipped -8, +8 lines =@@ - a(b); // Works - >a(b) : void - >a : (x: import("/node_modules/a/node_modules/x/index").default) => void -->b : import("/node_modules/a/node_modules/x/index").default -+>b : X - - a(c); // Error, these are from different versions of the library. - >a(c) : void -@@= skipped -25, +25 lines =@@ - - === /node_modules/b/index.d.ts === - import X from "x"; -->X : typeof X -+>X : any - - export const b: X; - >b : X - - === /node_modules/b/node_modules/x/index.d.ts === - content not parsed -->X : X -- -->x : number -+>content : any -+>not : any -+>parsed : any - - === /node_modules/c/index.d.ts === - import X from "x"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols index abc070a609..0b3ba9f899 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols @@ -23,6 +23,8 @@ export var y = 2 === /tests/node_modules/@types/react/index.d.ts === +>global : Symbol(global, Decl(index.d.ts, 0, 0)) + === /node_modules/@types/react/index.d.ts === declare global { } >global : Symbol(global, Decl(index.d.ts, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols.diff deleted file mode 100644 index 3de2625386..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.symbols.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.duplicatePackage_globalMerge.symbols -+++ new.duplicatePackage_globalMerge.symbols -@@= skipped -22, +22 lines =@@ - - === /tests/node_modules/@types/react/index.d.ts === - -->global : Symbol(global, Decl(index.d.ts, 0, 0)) -- - === /node_modules/@types/react/index.d.ts === - declare global { } - >global : Symbol(global, Decl(index.d.ts, 0, 0)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types index ecba91848d..920d6906dc 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types @@ -25,6 +25,8 @@ export var y = 2 === /tests/node_modules/@types/react/index.d.ts === +>global : typeof global + === /node_modules/@types/react/index.d.ts === declare global { } >global : typeof global diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types.diff deleted file mode 100644 index a280e89724..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_globalMerge.types.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.duplicatePackage_globalMerge.types -+++ new.duplicatePackage_globalMerge.types -@@= skipped -24, +24 lines =@@ - - === /tests/node_modules/@types/react/index.d.ts === - -->global : typeof global -- - === /node_modules/@types/react/index.d.ts === - declare global { } - >global : typeof global \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt deleted file mode 100644 index 954f20ec44..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt +++ /dev/null @@ -1,30 +0,0 @@ -/index.ts(4,5): error TS2322: Type 'import("/node_modules/a/node_modules/foo/index").Foo' is not assignable to type 'import("/node_modules/@types/foo/index").Foo'. - Types have separate declarations of a private property 'x'. - - -==== /index.ts (1 errors) ==== - import * as a from "a"; - import { Foo } from "foo"; - - let foo: Foo = a.foo; - ~~~ -!!! error TS2322: Type 'import("/node_modules/a/node_modules/foo/index").Foo' is not assignable to type 'import("/node_modules/@types/foo/index").Foo'. -!!! error TS2322: Types have separate declarations of a private property 'x'. - -==== /node_modules/a/index.d.ts (0 errors) ==== - /// - import { Foo } from "foo"; - export const foo: Foo; - -==== /node_modules/a/node_modules/foo/index.d.ts (0 errors) ==== - export class Foo { private x; } - -==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== - { "name": "foo", "version": "1.2.3" } - -==== /node_modules/@types/foo/index.d.ts (0 errors) ==== - export class Foo { private x; } - -==== /node_modules/@types/foo/package.json (0 errors) ==== - { "name": "foo", "version": "1.2.3" } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt.diff deleted file mode 100644 index 58e5b61220..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.errors.txt.diff +++ /dev/null @@ -1,34 +0,0 @@ ---- old.duplicatePackage_referenceTypes.errors.txt -+++ new.duplicatePackage_referenceTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.ts(4,5): error TS2322: Type 'import("/node_modules/a/node_modules/foo/index").Foo' is not assignable to type 'import("/node_modules/@types/foo/index").Foo'. -+ Types have separate declarations of a private property 'x'. -+ -+ -+==== /index.ts (1 errors) ==== -+ import * as a from "a"; -+ import { Foo } from "foo"; -+ -+ let foo: Foo = a.foo; -+ ~~~ -+!!! error TS2322: Type 'import("/node_modules/a/node_modules/foo/index").Foo' is not assignable to type 'import("/node_modules/@types/foo/index").Foo'. -+!!! error TS2322: Types have separate declarations of a private property 'x'. -+ -+==== /node_modules/a/index.d.ts (0 errors) ==== -+ /// -+ import { Foo } from "foo"; -+ export const foo: Foo; -+ -+==== /node_modules/a/node_modules/foo/index.d.ts (0 errors) ==== -+ export class Foo { private x; } -+ -+==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== -+ { "name": "foo", "version": "1.2.3" } -+ -+==== /node_modules/@types/foo/index.d.ts (0 errors) ==== -+ export class Foo { private x; } -+ -+==== /node_modules/@types/foo/package.json (0 errors) ==== -+ { "name": "foo", "version": "1.2.3" } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types index ac9be73082..c9c06c50d9 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types @@ -9,9 +9,9 @@ import { Foo } from "foo"; let foo: Foo = a.foo; >foo : Foo ->a.foo : import("/node_modules/a/node_modules/foo/index").Foo +>a.foo : Foo >a : typeof a ->foo : import("/node_modules/a/node_modules/foo/index").Foo +>foo : Foo === /node_modules/a/index.d.ts === /// diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types.diff deleted file mode 100644 index 80ed49bf27..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_referenceTypes.types.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.duplicatePackage_referenceTypes.types -+++ new.duplicatePackage_referenceTypes.types -@@= skipped -8, +8 lines =@@ - - let foo: Foo = a.foo; - >foo : Foo -->a.foo : Foo -+>a.foo : import("/node_modules/a/node_modules/foo/index").Foo - >a : typeof a -->foo : Foo -+>foo : import("/node_modules/a/node_modules/foo/index").Foo - - === /node_modules/a/index.d.ts === - /// \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt deleted file mode 100644 index 9f4f6d7f9b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -/index.ts(4,5): error TS2345: Argument of type 'import("/node_modules/a/node_modules/foo/index").C' is not assignable to parameter of type 'import("/node_modules/foo/index").C'. - Types have separate declarations of a private property 'x'. - - -==== /index.ts (1 errors) ==== - import { use } from "foo/use"; - import { o } from "a"; - - use(o); - ~ -!!! error TS2345: Argument of type 'import("/node_modules/a/node_modules/foo/index").C' is not assignable to parameter of type 'import("/node_modules/foo/index").C'. -!!! error TS2345: Types have separate declarations of a private property 'x'. - -==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== - { - "name": "foo", - "version": "1.2.3" - } - -==== /node_modules/a/node_modules/foo/index.d.ts (0 errors) ==== - export class C { - private x: number; - } - -==== /node_modules/a/index.d.ts (0 errors) ==== - import { C } from "foo"; - export const o: C; - -==== /node_modules/foo/use.d.ts (0 errors) ==== - import { C } from "./index"; - export function use(o: C): void; - -==== /node_modules/foo/index.d.ts (0 errors) ==== - export class C { - private x: number; - } - -==== /node_modules/foo/package.json (0 errors) ==== - { - "name": "foo", - "version": "1.2.3" - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt.diff deleted file mode 100644 index 6be7c60fc7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage.errors.txt -+++ new.duplicatePackage_relativeImportWithinPackage.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.ts(4,5): error TS2345: Argument of type 'import("/node_modules/a/node_modules/foo/index").C' is not assignable to parameter of type 'import("/node_modules/foo/index").C'. -+ Types have separate declarations of a private property 'x'. -+ -+ -+==== /index.ts (1 errors) ==== -+ import { use } from "foo/use"; -+ import { o } from "a"; -+ -+ use(o); -+ ~ -+!!! error TS2345: Argument of type 'import("/node_modules/a/node_modules/foo/index").C' is not assignable to parameter of type 'import("/node_modules/foo/index").C'. -+!!! error TS2345: Types have separate declarations of a private property 'x'. -+ -+==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== -+ { -+ "name": "foo", -+ "version": "1.2.3" -+ } -+ -+==== /node_modules/a/node_modules/foo/index.d.ts (0 errors) ==== -+ export class C { -+ private x: number; -+ } -+ -+==== /node_modules/a/index.d.ts (0 errors) ==== -+ import { C } from "foo"; -+ export const o: C; -+ -+==== /node_modules/foo/use.d.ts (0 errors) ==== -+ import { C } from "./index"; -+ export function use(o: C): void; -+ -+==== /node_modules/foo/index.d.ts (0 errors) ==== -+ export class C { -+ private x: number; -+ } -+ -+==== /node_modules/foo/package.json (0 errors) ==== -+ { -+ "name": "foo", -+ "version": "1.2.3" -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.trace.json b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.trace.json index dc6e3a92cf..8de27591a1 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.trace.json @@ -11,7 +11,7 @@ File '/node_modules/foo/use.tsx' does not exist. File '/node_modules/foo/use.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/foo/use.d.ts', result '/node_modules/foo/use.d.ts'. -======== Module name 'foo/use' was successfully resolved to '/node_modules/foo/use.d.ts' with Package ID 'foo@1.2.3'. ======== +======== Module name 'foo/use' was successfully resolved to '/node_modules/foo/use.d.ts' with Package ID 'foo/use.d.ts@1.2.3'. ======== ======== Resolving module 'a' from '/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -58,4 +58,4 @@ File '/node_modules/a/node_modules/foo/index.tsx' does not exist. File '/node_modules/a/node_modules/foo/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/a/node_modules/foo/index.d.ts', result '/node_modules/a/node_modules/foo/index.d.ts'. -======== Module name 'foo' was successfully resolved to '/node_modules/a/node_modules/foo/index.d.ts' with Package ID 'foo@1.2.3'. ======== +======== Module name 'foo' was successfully resolved to '/node_modules/a/node_modules/foo/index.d.ts' with Package ID 'foo/index.d.ts@1.2.3'. ======== diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types index 75d6b524f4..0993442b2d 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types @@ -5,12 +5,12 @@ import { use } from "foo/use"; >use : (o: import("/node_modules/foo/index").C) => void import { o } from "a"; ->o : import("/node_modules/a/node_modules/foo/index").C +>o : import("/node_modules/foo/index").C use(o); >use(o) : void >use : (o: import("/node_modules/foo/index").C) => void ->o : import("/node_modules/a/node_modules/foo/index").C +>o : import("/node_modules/foo/index").C === /node_modules/a/node_modules/foo/index.d.ts === export class C { diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types.diff deleted file mode 100644 index bd4b5c7d10..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage.types.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage.types -+++ new.duplicatePackage_relativeImportWithinPackage.types -@@= skipped -4, +4 lines =@@ - >use : (o: import("/node_modules/foo/index").C) => void - - import { o } from "a"; -->o : import("/node_modules/foo/index").C -+>o : import("/node_modules/a/node_modules/foo/index").C - - use(o); - >use(o) : void - >use : (o: import("/node_modules/foo/index").C) => void -->o : import("/node_modules/foo/index").C -+>o : import("/node_modules/a/node_modules/foo/index").C - - === /node_modules/a/node_modules/foo/index.d.ts === - export class C { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt deleted file mode 100644 index 19026366ac..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -/index.ts(4,5): error TS2345: Argument of type 'import("/node_modules/a/node_modules/@foo/bar/index").C' is not assignable to parameter of type 'import("/node_modules/@foo/bar/index").C'. - Types have separate declarations of a private property 'x'. - - -==== /index.ts (1 errors) ==== - import { use } from "@foo/bar/use"; - import { o } from "a"; - - use(o); - ~ -!!! error TS2345: Argument of type 'import("/node_modules/a/node_modules/@foo/bar/index").C' is not assignable to parameter of type 'import("/node_modules/@foo/bar/index").C'. -!!! error TS2345: Types have separate declarations of a private property 'x'. - -==== /node_modules/a/node_modules/@foo/bar/package.json (0 errors) ==== - { - "name": "@foo/bar", - "version": "1.2.3" - } - -==== /node_modules/a/node_modules/@foo/bar/index.d.ts (0 errors) ==== - export class C { - private x: number; - } - -==== /node_modules/a/index.d.ts (0 errors) ==== - import { C } from "@foo/bar"; - export const o: C; - -==== /node_modules/@foo/bar/use.d.ts (0 errors) ==== - import { C } from "./index"; - export function use(o: C): void; - -==== /node_modules/@foo/bar/index.d.ts (0 errors) ==== - export class C { - private x: number; - } - -==== /node_modules/@foo/bar/package.json (0 errors) ==== - { - "name": "@foo/bar", - "version": "1.2.3" - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt.diff deleted file mode 100644 index 5fd8e03f0b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage_scoped.errors.txt -+++ new.duplicatePackage_relativeImportWithinPackage_scoped.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.ts(4,5): error TS2345: Argument of type 'import("/node_modules/a/node_modules/@foo/bar/index").C' is not assignable to parameter of type 'import("/node_modules/@foo/bar/index").C'. -+ Types have separate declarations of a private property 'x'. -+ -+ -+==== /index.ts (1 errors) ==== -+ import { use } from "@foo/bar/use"; -+ import { o } from "a"; -+ -+ use(o); -+ ~ -+!!! error TS2345: Argument of type 'import("/node_modules/a/node_modules/@foo/bar/index").C' is not assignable to parameter of type 'import("/node_modules/@foo/bar/index").C'. -+!!! error TS2345: Types have separate declarations of a private property 'x'. -+ -+==== /node_modules/a/node_modules/@foo/bar/package.json (0 errors) ==== -+ { -+ "name": "@foo/bar", -+ "version": "1.2.3" -+ } -+ -+==== /node_modules/a/node_modules/@foo/bar/index.d.ts (0 errors) ==== -+ export class C { -+ private x: number; -+ } -+ -+==== /node_modules/a/index.d.ts (0 errors) ==== -+ import { C } from "@foo/bar"; -+ export const o: C; -+ -+==== /node_modules/@foo/bar/use.d.ts (0 errors) ==== -+ import { C } from "./index"; -+ export function use(o: C): void; -+ -+==== /node_modules/@foo/bar/index.d.ts (0 errors) ==== -+ export class C { -+ private x: number; -+ } -+ -+==== /node_modules/@foo/bar/package.json (0 errors) ==== -+ { -+ "name": "@foo/bar", -+ "version": "1.2.3" -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index 9e9981afde..39f2d2b98b 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -11,7 +11,7 @@ File '/node_modules/@foo/bar/use.tsx' does not exist. File '/node_modules/@foo/bar/use.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/@foo/bar/use.d.ts', result '/node_modules/@foo/bar/use.d.ts'. -======== Module name '@foo/bar/use' was successfully resolved to '/node_modules/@foo/bar/use.d.ts' with Package ID '@foo/bar@1.2.3'. ======== +======== Module name '@foo/bar/use' was successfully resolved to '/node_modules/@foo/bar/use.d.ts' with Package ID '@foo/bar/use.d.ts@1.2.3'. ======== ======== Resolving module 'a' from '/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -58,4 +58,4 @@ File '/node_modules/a/node_modules/@foo/bar/index.tsx' does not exist. File '/node_modules/a/node_modules/@foo/bar/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/a/node_modules/@foo/bar/index.d.ts', result '/node_modules/a/node_modules/@foo/bar/index.d.ts'. -======== Module name '@foo/bar' was successfully resolved to '/node_modules/a/node_modules/@foo/bar/index.d.ts' with Package ID '@foo/bar@1.2.3'. ======== +======== Module name '@foo/bar' was successfully resolved to '/node_modules/a/node_modules/@foo/bar/index.d.ts' with Package ID '@foo/bar/index.d.ts@1.2.3'. ======== diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types index 8fa6f0c879..927fdfa748 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types @@ -5,12 +5,12 @@ import { use } from "@foo/bar/use"; >use : (o: import("/node_modules/@foo/bar/index").C) => void import { o } from "a"; ->o : import("/node_modules/a/node_modules/@foo/bar/index").C +>o : import("/node_modules/@foo/bar/index").C use(o); >use(o) : void >use : (o: import("/node_modules/@foo/bar/index").C) => void ->o : import("/node_modules/a/node_modules/@foo/bar/index").C +>o : import("/node_modules/@foo/bar/index").C === /node_modules/a/node_modules/@foo/bar/index.d.ts === export class C { diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types.diff deleted file mode 100644 index 61dace3bcc..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_relativeImportWithinPackage_scoped.types.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.duplicatePackage_relativeImportWithinPackage_scoped.types -+++ new.duplicatePackage_relativeImportWithinPackage_scoped.types -@@= skipped -4, +4 lines =@@ - >use : (o: import("/node_modules/@foo/bar/index").C) => void - - import { o } from "a"; -->o : import("/node_modules/@foo/bar/index").C -+>o : import("/node_modules/a/node_modules/@foo/bar/index").C - - use(o); - >use(o) : void - >use : (o: import("/node_modules/@foo/bar/index").C) => void -->o : import("/node_modules/@foo/bar/index").C -+>o : import("/node_modules/a/node_modules/@foo/bar/index").C - - === /node_modules/a/node_modules/@foo/bar/index.d.ts === - export class C { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt deleted file mode 100644 index a7412affa6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt +++ /dev/null @@ -1,33 +0,0 @@ -/index.ts(4,7): error TS2322: Type 'import("/node_modules/a/node_modules/foo/Foo").default' is not assignable to type 'import("/node_modules/foo/Foo").default'. - Property 'source' is protected but type 'Foo' is not a class derived from 'Foo'. - - -==== /index.ts (1 errors) ==== - import Foo from "foo/Foo"; - import * as a from "a"; - - const o: Foo = a.o; - ~ -!!! error TS2322: Type 'import("/node_modules/a/node_modules/foo/Foo").default' is not assignable to type 'import("/node_modules/foo/Foo").default'. -!!! error TS2322: Property 'source' is protected but type 'Foo' is not a class derived from 'Foo'. - -==== /node_modules/a/index.d.ts (0 errors) ==== - import Foo from "foo/Foo"; - export const o: Foo; - -==== /node_modules/a/node_modules/foo/Foo.d.ts (0 errors) ==== - export default class Foo { - protected source: boolean; - } - -==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== - { "name": "foo", "version": "1.2.3" } - -==== /node_modules/foo/Foo.d.ts (0 errors) ==== - export default class Foo { - protected source: boolean; - } - -==== /node_modules/foo/package.json (0 errors) ==== - { "name": "foo", "version": "1.2.3" } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt.diff deleted file mode 100644 index 7fb6c1ad0b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.errors.txt.diff +++ /dev/null @@ -1,37 +0,0 @@ ---- old.duplicatePackage_subModule.errors.txt -+++ new.duplicatePackage_subModule.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/index.ts(4,7): error TS2322: Type 'import("/node_modules/a/node_modules/foo/Foo").default' is not assignable to type 'import("/node_modules/foo/Foo").default'. -+ Property 'source' is protected but type 'Foo' is not a class derived from 'Foo'. -+ -+ -+==== /index.ts (1 errors) ==== -+ import Foo from "foo/Foo"; -+ import * as a from "a"; -+ -+ const o: Foo = a.o; -+ ~ -+!!! error TS2322: Type 'import("/node_modules/a/node_modules/foo/Foo").default' is not assignable to type 'import("/node_modules/foo/Foo").default'. -+!!! error TS2322: Property 'source' is protected but type 'Foo' is not a class derived from 'Foo'. -+ -+==== /node_modules/a/index.d.ts (0 errors) ==== -+ import Foo from "foo/Foo"; -+ export const o: Foo; -+ -+==== /node_modules/a/node_modules/foo/Foo.d.ts (0 errors) ==== -+ export default class Foo { -+ protected source: boolean; -+ } -+ -+==== /node_modules/a/node_modules/foo/package.json (0 errors) ==== -+ { "name": "foo", "version": "1.2.3" } -+ -+==== /node_modules/foo/Foo.d.ts (0 errors) ==== -+ export default class Foo { -+ protected source: boolean; -+ } -+ -+==== /node_modules/foo/package.json (0 errors) ==== -+ { "name": "foo", "version": "1.2.3" } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types index 7767de1d94..976b785722 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types @@ -9,9 +9,9 @@ import * as a from "a"; const o: Foo = a.o; >o : Foo ->a.o : import("/node_modules/a/node_modules/foo/Foo").default +>a.o : Foo >a : typeof a ->o : import("/node_modules/a/node_modules/foo/Foo").default +>o : Foo === /node_modules/a/index.d.ts === import Foo from "foo/Foo"; diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types.diff deleted file mode 100644 index 25738a74af..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_subModule.types.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.duplicatePackage_subModule.types -+++ new.duplicatePackage_subModule.types -@@= skipped -8, +8 lines =@@ - - const o: Foo = a.o; - >o : Foo -->a.o : Foo -+>a.o : import("/node_modules/a/node_modules/foo/Foo").default - >a : typeof a -->o : Foo -+>o : import("/node_modules/a/node_modules/foo/Foo").default - - === /node_modules/a/index.d.ts === - import Foo from "foo/Foo"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt index 090ca51dd3..89cc598606 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt @@ -1,10 +1,4 @@ /node_modules/a/node_modules/x/index.d.ts(1,18): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. -/node_modules/b/index.d.ts(1,19): error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. -/node_modules/b/node_modules/x/index.d.ts(1,1): error TS1434: Unexpected keyword or identifier. -/node_modules/b/node_modules/x/index.d.ts(1,1): error TS2304: Cannot find name 'content'. -/node_modules/b/node_modules/x/index.d.ts(1,9): error TS1434: Unexpected keyword or identifier. -/node_modules/b/node_modules/x/index.d.ts(1,9): error TS2304: Cannot find name 'not'. -/node_modules/b/node_modules/x/index.d.ts(1,13): error TS2304: Cannot find name 'parsed'. ==== /src/a.ts (0 errors) ==== @@ -22,23 +16,11 @@ ==== /node_modules/a/node_modules/x/package.json (0 errors) ==== { "name": "x", "version": "1.2.3" } -==== /node_modules/b/index.d.ts (1 errors) ==== +==== /node_modules/b/index.d.ts (0 errors) ==== export { x } from "x"; - ~~~ -!!! error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. -==== /node_modules/b/node_modules/x/index.d.ts (5 errors) ==== +==== /node_modules/b/node_modules/x/index.d.ts (0 errors) ==== content not parsed - ~~~~~~~ -!!! error TS1434: Unexpected keyword or identifier. - ~~~~~~~ -!!! error TS2304: Cannot find name 'content'. - ~~~ -!!! error TS1434: Unexpected keyword or identifier. - ~~~ -!!! error TS2304: Cannot find name 'not'. - ~~~~~~ -!!! error TS2304: Cannot find name 'parsed'. ==== /node_modules/b/node_modules/x/package.json (0 errors) ==== { "name": "x", "version": "1.2.3" } diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt.diff deleted file mode 100644 index 8885fbc2f7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.errors.txt.diff +++ /dev/null @@ -1,39 +0,0 @@ ---- old.duplicatePackage_withErrors.errors.txt -+++ new.duplicatePackage_withErrors.errors.txt -@@= skipped -0, +0 lines =@@ - /node_modules/a/node_modules/x/index.d.ts(1,18): error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. -+/node_modules/b/index.d.ts(1,19): error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. -+/node_modules/b/node_modules/x/index.d.ts(1,1): error TS1434: Unexpected keyword or identifier. -+/node_modules/b/node_modules/x/index.d.ts(1,1): error TS2304: Cannot find name 'content'. -+/node_modules/b/node_modules/x/index.d.ts(1,9): error TS1434: Unexpected keyword or identifier. -+/node_modules/b/node_modules/x/index.d.ts(1,9): error TS2304: Cannot find name 'not'. -+/node_modules/b/node_modules/x/index.d.ts(1,13): error TS2304: Cannot find name 'parsed'. - - - ==== /src/a.ts (0 errors) ==== -@@= skipped -15, +21 lines =@@ - ==== /node_modules/a/node_modules/x/package.json (0 errors) ==== - { "name": "x", "version": "1.2.3" } - --==== /node_modules/b/index.d.ts (0 errors) ==== -+==== /node_modules/b/index.d.ts (1 errors) ==== - export { x } from "x"; -+ ~~~ -+!!! error TS2306: File '/node_modules/b/node_modules/x/index.d.ts' is not a module. - --==== /node_modules/b/node_modules/x/index.d.ts (0 errors) ==== -+==== /node_modules/b/node_modules/x/index.d.ts (5 errors) ==== - content not parsed -+ ~~~~~~~ -+!!! error TS1434: Unexpected keyword or identifier. -+ ~~~~~~~ -+!!! error TS2304: Cannot find name 'content'. -+ ~~~ -+!!! error TS1434: Unexpected keyword or identifier. -+ ~~~ -+!!! error TS2304: Cannot find name 'not'. -+ ~~~~~~ -+!!! error TS2304: Cannot find name 'parsed'. - - ==== /node_modules/b/node_modules/x/package.json (0 errors) ==== - { "name": "x", "version": "1.2.3" } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols index a8df9c4b12..76a9124077 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols @@ -22,6 +22,6 @@ export { x } from "x"; >x : Symbol(x, Decl(index.d.ts, 0, 8)) === /node_modules/b/node_modules/x/index.d.ts === - content not parsed +>x : Symbol(x, Decl(index.d.ts, 0, 12)) diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols.diff deleted file mode 100644 index 666f32f2ad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.symbols.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.duplicatePackage_withErrors.symbols -+++ new.duplicatePackage_withErrors.symbols -@@= skipped -21, +21 lines =@@ - >x : Symbol(x, Decl(index.d.ts, 0, 8)) - - === /node_modules/b/node_modules/x/index.d.ts === -+ - content not parsed -->x : Symbol(x, Decl(index.d.ts, 0, 12)) diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types index f1e33a4617..e96c81fd63 100644 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types +++ b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types @@ -6,8 +6,8 @@ import { x as xa } from "a"; >xa : number import { x as xb } from "b"; ->x : any ->xb : any +>x : number +>xb : number === /node_modules/a/index.d.ts === export { x } from "x"; @@ -22,11 +22,12 @@ export const x = 1 + 1; === /node_modules/b/index.d.ts === export { x } from "x"; ->x : any +>x : number === /node_modules/b/node_modules/x/index.d.ts === content not parsed ->content : any ->not : any ->parsed : any +>x : number +>1 + 1 : number +>1 : 1 +>1 : 1 diff --git a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types.diff b/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types.diff deleted file mode 100644 index 6f962c0e97..0000000000 --- a/testdata/baselines/reference/submodule/compiler/duplicatePackage_withErrors.types.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.duplicatePackage_withErrors.types -+++ new.duplicatePackage_withErrors.types -@@= skipped -5, +5 lines =@@ - >xa : number - - import { x as xb } from "b"; -->x : number -->xb : number -+>x : any -+>xb : any - - === /node_modules/a/index.d.ts === - export { x } from "x"; -@@= skipped -16, +16 lines =@@ - - === /node_modules/b/index.d.ts === - export { x } from "x"; -->x : number -+>x : any - - === /node_modules/b/node_modules/x/index.d.ts === - content not parsed -->x : number -->1 + 1 : number -->1 : 1 -->1 : 1 -+>content : any -+>not : any -+>parsed : any diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot.trace.json b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot.trace.json index f47943dc9e..642813b1a2 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot.trace.json +++ b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot.trace.json @@ -25,4 +25,4 @@ File '/node_modules/foo/bar.jsx' does not exist. File '/node_modules/foo/bar/index.js' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/foo/bar/index.js', result '/node_modules/foo/bar/index.js'. -======== Module name 'foo/bar' was successfully resolved to '/node_modules/foo/bar/index.js' with Package ID 'foo@1.2.3'. ======== +======== Module name 'foo/bar' was successfully resolved to '/node_modules/foo/bar/index.js' with Package ID 'foo/bar/index.js@1.2.3'. ======== diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json index 6dd76efa8d..c75b64190d 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json +++ b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json @@ -25,4 +25,4 @@ File '/node_modules/foo/@bar.jsx' does not exist. File '/node_modules/foo/@bar/index.js' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/foo/@bar/index.js', result '/node_modules/foo/@bar/index.js'. -======== Module name 'foo/@bar' was successfully resolved to '/node_modules/foo/@bar/index.js' with Package ID 'foo@1.2.3'. ======== +======== Module name 'foo/@bar' was successfully resolved to '/node_modules/foo/@bar/index.js' with Package ID 'foo/@bar/index.js@1.2.3'. ======== diff --git a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json index eeba5d48f4..9ab3791dde 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json +++ b/testdata/baselines/reference/submodule/compiler/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json @@ -18,4 +18,4 @@ File '/node_modules/foo/src/index.tsx' does not exist. File '/node_modules/foo/src/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/foo/src/index.d.ts', result '/node_modules/foo/src/index.d.ts'. -======== Module name 'foo' was successfully resolved to '/node_modules/foo/src/index.d.ts' with Package ID 'foo@1.2.3'. ======== +======== Module name 'foo' was successfully resolved to '/node_modules/foo/src/index.d.ts' with Package ID 'foo/src/index.d.ts@1.2.3'. ======== diff --git a/testdata/baselines/reference/submodule/compiler/reactJsxReactResolvedNodeNext.trace.json b/testdata/baselines/reference/submodule/compiler/reactJsxReactResolvedNodeNext.trace.json index 590f425b3a..028a3d5f62 100644 --- a/testdata/baselines/reference/submodule/compiler/reactJsxReactResolvedNodeNext.trace.json +++ b/testdata/baselines/reference/submodule/compiler/reactJsxReactResolvedNodeNext.trace.json @@ -10,7 +10,7 @@ Found 'package.json' at '/.src/node_modules/@types/react/package.json'. File '/.src/node_modules/@types/react/jsx-runtime.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/@types/react/jsx-runtime.d.ts', result '/.src/node_modules/@types/react/jsx-runtime.d.ts'. -======== Module name 'react/jsx-runtime' was successfully resolved to '/.src/node_modules/@types/react/jsx-runtime.d.ts' with Package ID '@types/react@0.0.1'. ======== +======== Module name 'react/jsx-runtime' was successfully resolved to '/.src/node_modules/@types/react/jsx-runtime.d.ts' with Package ID '@types/react/jsx-runtime.d.ts@0.0.1'. ======== ======== Resolving module './' from '/.src/node_modules/@types/react/jsx-runtime.d.ts'. ======== Module resolution kind is not specified, using 'NodeNext'. Resolving in CJS mode with conditions 'require', 'types', 'node'. diff --git a/testdata/baselines/reference/submodule/conformance/customConditions(resolvepackagejsonexports=false).trace.json b/testdata/baselines/reference/submodule/conformance/customConditions(resolvepackagejsonexports=false).trace.json index 2f3ee4888b..96a621363a 100644 --- a/testdata/baselines/reference/submodule/conformance/customConditions(resolvepackagejsonexports=false).trace.json +++ b/testdata/baselines/reference/submodule/conformance/customConditions(resolvepackagejsonexports=false).trace.json @@ -18,4 +18,4 @@ File '/node_modules/lodash/index.tsx' does not exist. File '/node_modules/lodash/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/node_modules/lodash/index.d.ts', result '/node_modules/lodash/index.d.ts'. -======== Module name 'lodash' was successfully resolved to '/node_modules/lodash/index.d.ts' with Package ID 'lodash@1.0.0'. ======== +======== Module name 'lodash' was successfully resolved to '/node_modules/lodash/index.d.ts' with Package ID 'lodash/index.d.ts@1.0.0'. ======== diff --git a/testdata/baselines/reference/submodule/conformance/typesVersions.ambientModules.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersions.ambientModules.trace.json index 3880078ee4..3cd5db8e87 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersions.ambientModules.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersions.ambientModules.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. diff --git a/testdata/baselines/reference/submodule/conformance/typesVersions.multiFile.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersions.multiFile.trace.json index 27fef0f583..dd86ae732a 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersions.multiFile.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersions.multiFile.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -39,4 +39,4 @@ File '/.src/node_modules/ext/ts3.1/other.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/other.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/other.d.ts', result '/.src/node_modules/ext/ts3.1/other.d.ts'. -======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext/ts3.1/other.d.ts@1.0.0'. ======== diff --git a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.ambient.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.ambient.trace.json index 3880078ee4..3cd5db8e87 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.ambient.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.ambient.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. diff --git a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFile.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFile.trace.json index 27fef0f583..dd86ae732a 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFile.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -39,4 +39,4 @@ File '/.src/node_modules/ext/ts3.1/other.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/other.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/other.d.ts', result '/.src/node_modules/ext/ts3.1/other.d.ts'. -======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext/ts3.1/other.d.ts@1.0.0'. ======== diff --git a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index e5390b7825..539fad4d83 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -39,7 +39,7 @@ File '/.src/node_modules/ext/ts3.1/other.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/other.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/other.d.ts', result '/.src/node_modules/ext/ts3.1/other.d.ts'. -======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext/ts3.1/other.d.ts@1.0.0'. ======== ======== Resolving module '../' from '/.src/node_modules/ext/ts3.1/index.d.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. diff --git a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index 59839558cf..1147e4d6c5 100644 --- a/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/testdata/baselines/reference/submodule/conformance/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -21,7 +21,7 @@ File '/.src/node_modules/ext/ts3.1/index.tsx' does not exist. File '/.src/node_modules/ext/ts3.1/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/ts3.1/index.d.ts', result '/.src/node_modules/ext/ts3.1/index.d.ts'. -======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext' was successfully resolved to '/.src/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ======== ======== Resolving module 'ext/other' from '/.src/main.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -37,7 +37,7 @@ File '/.src/node_modules/ext/other.tsx' does not exist. File '/.src/node_modules/ext/other.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/.src/node_modules/ext/other.d.ts', result '/.src/node_modules/ext/other.d.ts'. -======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/other.d.ts' with Package ID 'ext@1.0.0'. ======== +======== Module name 'ext/other' was successfully resolved to '/.src/node_modules/ext/other.d.ts' with Package ID 'ext/other.d.ts@1.0.0'. ======== ======== Resolving module '../other' from '/.src/node_modules/ext/ts3.1/index.d.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/duplicatePackageServices.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/duplicatePackageServices.baseline.jsonc new file mode 100644 index 0000000000..9e286c69af --- /dev/null +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/duplicatePackageServices.baseline.jsonc @@ -0,0 +1,21 @@ +// === goToDefinition === +// === /node_modules/a/node_modules/x/index.d.ts === +// <|export default class [|X|] { +// private x: number; +// }|> + +// === /node_modules/a/index.d.ts === +// import [|X|]/*GOTO DEF*/ from "x"; +// export function a(x: X): void; + + + +// === goToDefinition === +// === /node_modules/a/node_modules/x/index.d.ts === +// <|export default class [|X|] { +// private x: number; +// }|> + +// === /node_modules/b/index.d.ts === +// import [|X|]/*GOTO DEF*/ from "x"; +// export const b: X; \ No newline at end of file diff --git a/testdata/baselines/reference/tsbuild/commandLine/help.js b/testdata/baselines/reference/tsbuild/commandLine/help.js index 856a112bfc..37d3b89b95 100644 --- a/testdata/baselines/reference/tsbuild/commandLine/help.js +++ b/testdata/baselines/reference/tsbuild/commandLine/help.js @@ -104,6 +104,11 @@ Disable full type checking (only critical parse and emit errors will be reported type: boolean default: false +--deduplicatePackages +Deduplicate packages with the same name and version. +type: boolean +default: true + --noEmit Disable emitting files from a compilation. type: boolean diff --git a/testdata/baselines/reference/tsbuild/commandLine/locale.js b/testdata/baselines/reference/tsbuild/commandLine/locale.js index 26271d5f01..bbdd99f583 100644 --- a/testdata/baselines/reference/tsbuild/commandLine/locale.js +++ b/testdata/baselines/reference/tsbuild/commandLine/locale.js @@ -104,6 +104,11 @@ Disable full type checking (only critical parse and emit errors will be reported type: boolean default: false +--deduplicatePackages +Deduplicate packages with the same name and version. +type: boolean +default: true + --noEmit Disable emitting files from a compilation. type: boolean diff --git a/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js b/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js index 45b4bc5898..034091b199 100644 --- a/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js +++ b/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js @@ -88,7 +88,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does n File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. -======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' with Package ID 'pkg2@1.0.0'. ======== +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== ======== Resolving module 'const' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Bundler'. diff --git a/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js b/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js index 3744082d9d..e121e2932d 100644 --- a/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js +++ b/testdata/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js @@ -89,7 +89,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. -======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2@1.0.0'. ======== +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== ======== Resolving module 'const' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Bundler'. diff --git a/testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js b/testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js index e9cdbb7c50..098eebd9bc 100644 --- a/testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js +++ b/testdata/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js @@ -86,7 +86,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. -======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2@1.0.0'. ======== +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== ======== Resolving module './const.js' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Bundler'. diff --git a/testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index 44005f7815..c9827a6f33 100644 --- a/testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/testdata/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -85,7 +85,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. -======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2@1.0.0'. ======== +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. @@ -383,7 +383,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.cts' does File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.cts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.cts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.cts'. -======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.cts' with Package ID 'pkg2@1.0.0'. ======== +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.cts' with Package ID 'pkg2/build/index.d.cts@1.0.0'. ======== ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node16'. diff --git a/testdata/baselines/reference/tsc/commandLine/help-all.js b/testdata/baselines/reference/tsc/commandLine/help-all.js index 5e561d8833..bd4ff598e3 100644 --- a/testdata/baselines/reference/tsc/commandLine/help-all.js +++ b/testdata/baselines/reference/tsc/commandLine/help-all.js @@ -221,6 +221,11 @@ Ensure 'use strict' is always emitted. type: boolean default: `false`, unless `strict` is set +--deduplicatePackages +Deduplicate packages with the same name and version. +type: boolean +default: true + --exactOptionalPropertyTypes Interpret optional property types as written, rather than adding 'undefined'. type: boolean diff --git a/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js b/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js index 710a6e7b26..914182b948 100644 --- a/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js +++ b/testdata/baselines/reference/tsc/declarationEmit/when-pkg-references-sibling-package-through-indirect-symlink.js @@ -68,11 +68,11 @@ Output:: pkg1/dist/types.d.ts Imported via './types' from file 'pkg1/dist/index.d.ts' pkg1/dist/index.d.ts - Imported via '@raymondfeng/pkg1' from file 'pkg2/dist/types.d.ts' with packageId '@raymondfeng/pkg1@1.0.0' + Imported via '@raymondfeng/pkg1' from file 'pkg2/dist/types.d.ts' with packageId '@raymondfeng/pkg1/dist/index.d.ts@1.0.0' pkg2/dist/types.d.ts Imported via './types' from file 'pkg2/dist/index.d.ts' pkg2/dist/index.d.ts - Imported via "@raymondfeng/pkg2" from file 'pkg3/src/keys.ts' with packageId '@raymondfeng/pkg2@1.0.0' + Imported via "@raymondfeng/pkg2" from file 'pkg3/src/keys.ts' with packageId '@raymondfeng/pkg2/dist/index.d.ts@1.0.0' pkg3/src/keys.ts Imported via './keys' from file 'pkg3/src/index.ts' Matched by default include pattern '**/*' diff --git a/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js b/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js index 5cfa0d4d57..8a3a24113f 100644 --- a/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js +++ b/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js @@ -112,7 +112,7 @@ File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/ File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.d.ts', result '/user/username/projects/myproject/plugin-two/dist/commonjs/index.d.ts'. -======== Module name 'plugin-two' was successfully resolved to '/user/username/projects/myproject/plugin-two/dist/commonjs/index.d.ts' with Package ID 'plugin-two@0.1.3'. ======== +======== Module name 'plugin-two' was successfully resolved to '/user/username/projects/myproject/plugin-two/dist/commonjs/index.d.ts' with Package ID 'plugin-two/dist/commonjs/index.d.ts@0.1.3'. ======== ======== Resolving module 'typescript-fsa' from '/user/username/projects/myproject/plugin-one/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -137,7 +137,7 @@ File '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/i File '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts', result '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts'. -======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa@3.0.0-beta-2'. ======== +======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa/index.d.ts@3.0.0-beta-2'. ======== ======== Resolving module 'typescript-fsa' from '/user/username/projects/myproject/plugin-two/dist/commonjs/index.d.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -163,15 +163,13 @@ File '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/i File '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts', result '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts'. -======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa@3.0.0-beta-2'. ======== +======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa/index.d.ts@3.0.0-beta-2'. ======== ../../../../home/src/tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' plugin-two/node_modules/typescript-fsa/index.d.ts - Imported via "typescript-fsa" from file 'plugin-two/dist/commonjs/index.d.ts' with packageId 'typescript-fsa@3.0.0-beta-2' + Imported via "typescript-fsa" from file 'plugin-two/dist/commonjs/index.d.ts' with packageId 'typescript-fsa/index.d.ts@3.0.0-beta-2' plugin-two/dist/commonjs/index.d.ts - Imported via "plugin-two" from file 'plugin-one/index.ts' with packageId 'plugin-two@0.1.3' -plugin-one/node_modules/typescript-fsa/index.d.ts - Imported via "typescript-fsa" from file 'plugin-one/index.ts' with packageId 'typescript-fsa@3.0.0-beta-2' + Imported via "plugin-two" from file 'plugin-one/index.ts' with packageId 'plugin-two/dist/commonjs/index.d.ts@0.1.3' plugin-one/index.ts Matched by default include pattern '**/*' //// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* diff --git a/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package.js index 83b1575d13..fc9f6e3c5d 100644 --- a/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package.js +++ b/testdata/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -105,7 +105,7 @@ File '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/i File '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts', result '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts'. -======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa@3.0.0-beta-2'. ======== +======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-one/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa/index.d.ts@3.0.0-beta-2'. ======== ======== Resolving module 'plugin-two' from '/user/username/projects/myproject/plugin-one/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'require', 'types'. @@ -150,15 +150,13 @@ File '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/i File '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts', result '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts'. -======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa@3.0.0-beta-2'. ======== +======== Module name 'typescript-fsa' was successfully resolved to '/user/username/projects/myproject/plugin-two/node_modules/typescript-fsa/index.d.ts' with Package ID 'typescript-fsa/index.d.ts@3.0.0-beta-2'. ======== ../../../../home/src/tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' plugin-one/node_modules/typescript-fsa/index.d.ts - Imported via "typescript-fsa" from file 'plugin-one/action.ts' with packageId 'typescript-fsa@3.0.0-beta-2' + Imported via "typescript-fsa" from file 'plugin-one/action.ts' with packageId 'typescript-fsa/index.d.ts@3.0.0-beta-2' plugin-one/action.ts Matched by default include pattern '**/*' -plugin-two/node_modules/typescript-fsa/index.d.ts - Imported via "typescript-fsa" from file 'plugin-two/index.d.ts' with packageId 'typescript-fsa@3.0.0-beta-2' plugin-two/index.d.ts Imported via "plugin-two" from file 'plugin-one/index.ts' plugin-one/index.ts diff --git a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js index 01e668625c..3c2149a1b2 100644 --- a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js +++ b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js @@ -134,7 +134,7 @@ File '/home/src/projects/component-type-checker/packages/app/node_modules/@compo File '/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/sdk/src/index.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/sdk/src/index.ts', result '/home/src/projects/component-type-checker/packages/sdk/src/index.ts'. -======== Module name '@component-type-checker/sdk' was successfully resolved to '/home/src/projects/component-type-checker/packages/sdk/src/index.ts' with Package ID '@component-type-checker/sdk1@0.0.2'. ======== +======== Module name '@component-type-checker/sdk' was successfully resolved to '/home/src/projects/component-type-checker/packages/sdk/src/index.ts' with Package ID '@component-type-checker/sdk1/src/index.ts@0.0.2'. ======== ======== Resolving module '@component-type-checker/components' from '/home/src/projects/component-type-checker/packages/app/src/app.tsx'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. @@ -159,7 +159,7 @@ Resolving real path for '/home/src/projects/component-type-checker/packages/app/ Found 'package.json' at '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/package.json'. Found peerDependency '@component-type-checker/button' with '0.0.2' version. Resolving real path for '/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/components/src/index.ts', result '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts'. -======== Module name '@component-type-checker/components' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts' with Package ID '@component-type-checker/components@0.0.1+@component-type-checker/button@0.0.2'. ======== +======== Module name '@component-type-checker/components' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts' with Package ID '@component-type-checker/components/src/index.ts@0.0.1+@component-type-checker/button@0.0.2'. ======== ======== Resolving module '@component-type-checker/button' from '/home/src/projects/component-type-checker/packages/app/src/app.tsx'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. @@ -181,7 +181,7 @@ File '/home/src/projects/component-type-checker/packages/app/node_modules/@compo File '/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/button/src/index.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/home/src/projects/component-type-checker/packages/app/node_modules/@component-type-checker/button/src/index.ts', result '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts'. -======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button@0.0.2'. ======== +======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button/src/index.ts@0.0.2'. ======== ======== Resolving module '@component-type-checker/components' from '/home/src/projects/component-type-checker/packages/sdk/src/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. @@ -206,7 +206,7 @@ Resolving real path for '/home/src/projects/component-type-checker/packages/sdk/ Found 'package.json' at '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/package.json'. Found peerDependency '@component-type-checker/button' with '0.0.1' version. Resolving real path for '/home/src/projects/component-type-checker/packages/sdk/node_modules/@component-type-checker/components/src/index.ts', result '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts'. -======== Module name '@component-type-checker/components' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts' with Package ID '@component-type-checker/components@0.0.1+@component-type-checker/button@0.0.1'. ======== +======== Module name '@component-type-checker/components' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts' with Package ID '@component-type-checker/components/src/index.ts@0.0.1+@component-type-checker/button@0.0.1'. ======== ======== Resolving module '@component-type-checker/button' from '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. @@ -234,7 +234,7 @@ File '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-ty File '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts', result '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts'. -======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button@0.0.1'. ======== +======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button/src/index.ts@0.0.1'. ======== ======== Resolving module '@component-type-checker/button' from '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts'. ======== Module resolution kind is not specified, using 'Bundler'. Resolving in CJS mode with conditions 'import', 'types'. @@ -262,20 +262,20 @@ File '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-ty File '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. Resolving real path for '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts', result '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts'. -======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button@0.0.2'. ======== +======== Module name '@component-type-checker/button' was successfully resolved to '/home/src/projects/component-type-checker/node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts' with Package ID '@component-type-checker/button/src/index.ts@0.0.2'. ======== ../../../../tslibs/TS/Lib/lib.es5.d.ts Library 'lib.es5.d.ts' specified in compilerOptions ../../node_modules/.pnpm/@component-type-checker+button@0.0.1/node_modules/@component-type-checker/button/src/index.ts - Imported via "@component-type-checker/button" from file '../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts' with packageId '@component-type-checker/button@0.0.1' + Imported via "@component-type-checker/button" from file '../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts' with packageId '@component-type-checker/button/src/index.ts@0.0.1' ../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.1/node_modules/@component-type-checker/components/src/index.ts - Imported via "@component-type-checker/components" from file '../sdk/src/index.ts' with packageId '@component-type-checker/components@0.0.1+@component-type-checker/button@0.0.1' + Imported via "@component-type-checker/components" from file '../sdk/src/index.ts' with packageId '@component-type-checker/components/src/index.ts@0.0.1+@component-type-checker/button@0.0.1' ../sdk/src/index.ts - Imported via "@component-type-checker/sdk" from file 'src/app.tsx' with packageId '@component-type-checker/sdk1@0.0.2' + Imported via "@component-type-checker/sdk" from file 'src/app.tsx' with packageId '@component-type-checker/sdk1/src/index.ts@0.0.2' ../../node_modules/.pnpm/@component-type-checker+button@0.0.2/node_modules/@component-type-checker/button/src/index.ts - Imported via "@component-type-checker/button" from file '../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts' with packageId '@component-type-checker/button@0.0.2' - Imported via "@component-type-checker/button" from file 'src/app.tsx' with packageId '@component-type-checker/button@0.0.2' + Imported via "@component-type-checker/button" from file '../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts' with packageId '@component-type-checker/button/src/index.ts@0.0.2' + Imported via "@component-type-checker/button" from file 'src/app.tsx' with packageId '@component-type-checker/button/src/index.ts@0.0.2' ../../node_modules/.pnpm/@component-type-checker+components@0.0.1_@component-type-checker+button@0.0.2/node_modules/@component-type-checker/components/src/index.ts - Imported via "@component-type-checker/components" from file 'src/app.tsx' with packageId '@component-type-checker/components@0.0.1+@component-type-checker/button@0.0.2' + Imported via "@component-type-checker/components" from file 'src/app.tsx' with packageId '@component-type-checker/components/src/index.ts@0.0.1+@component-type-checker/button@0.0.2' src/app.tsx Matched by include pattern 'src' in 'tsconfig.json' //// [/home/src/projects/component-type-checker/packages/app/dist/app.js] *new* diff --git a/testdata/tests/cases/compiler/deduplicatePackages.ts b/testdata/tests/cases/compiler/deduplicatePackages.ts new file mode 100644 index 0000000000..684e9283e3 --- /dev/null +++ b/testdata/tests/cases/compiler/deduplicatePackages.ts @@ -0,0 +1,43 @@ +// @noImplicitReferences: true +// @deduplicatePackages: true,false + +// @Filename: /node_modules/a/index.d.ts +import X from "x"; +export function a(x: X): void; + +// @Filename: /node_modules/a/node_modules/x/index.d.ts +export default class X { + private x: number; +} + +// @Filename: /node_modules/a/node_modules/x/package.json +{ "name": "x", "version": "1.2.3" } + +// @Filename: /node_modules/b/index.d.ts +import X from "x"; +export const b: X; + +// @Filename: /node_modules/b/node_modules/x/index.d.ts +content not parsed + +// @Filename: /node_modules/b/node_modules/x/package.json +{ "name": "x", "version": "1.2.3" } + +// @Filename: /node_modules/c/index.d.ts +import X from "x"; +export const c: X; + +// @Filename: /node_modules/c/node_modules/x/index.d.ts +export default class X { + private x: number; +} + +// @Filename: /node_modules/c/node_modules/x/package.json +{ "name": "x", "version": "1.2.4" } + +// @Filename: /src/a.ts +import { a } from "a"; +import { b } from "b"; +import { c } from "c"; +a(b); // Works +a(c); // Error, these are from different versions of the library. diff --git a/testdata/tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts b/testdata/tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts new file mode 100644 index 0000000000..2209322a15 --- /dev/null +++ b/testdata/tests/cases/compiler/packageDeduplicationDuplicateGlobals.ts @@ -0,0 +1,60 @@ +// @strict: true +// @noImplicitReferences: true + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/foo/package.json +{ "name": "foo", "version": "1.0.0" } + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/foo/index.d.ts +import "globals"; +export declare function useFoo(): typeof myGlobal; + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/globals/package.json +{ "name": "globals", "version": "1.0.0" } + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/globals/index.d.ts +declare var myGlobal: string; + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/foo/package.json +{ "name": "foo", "version": "1.0.0" } + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/foo/index.d.ts +import "globals"; +export declare function useFoo(): typeof myGlobal; + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/globals/package.json +{ "name": "globals", "version": "2.0.0" } + +// @filename: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/globals/index.d.ts +declare var myGlobal: number; + +// @filename: /node_modules/.pnpm/bar@1.0.0/node_modules/bar/package.json +{ "name": "bar", "version": "1.0.0" } + +// @filename: /node_modules/.pnpm/bar@1.0.0/node_modules/bar/index.d.ts +import { useFoo } from "foo"; +export declare function useBar(): ReturnType; + +// @filename: /node_modules/.pnpm/baz@1.0.0/node_modules/baz/package.json +{ "name": "baz", "version": "1.0.0" } + +// @filename: /node_modules/.pnpm/baz@1.0.0/node_modules/baz/index.d.ts +import { useFoo } from "foo"; +export declare function useBaz(): ReturnType; + +// @link: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/foo -> /node_modules/.pnpm/bar@1.0.0/node_modules/foo +// @link: /node_modules/.pnpm/foo@1.0.0+globals@1.0.0/node_modules/globals -> /node_modules/.pnpm/bar@1.0.0/node_modules/globals + +// @link: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/foo -> /node_modules/.pnpm/baz@1.0.0/node_modules/foo +// @link: /node_modules/.pnpm/foo@1.0.0+globals@2.0.0/node_modules/globals -> /node_modules/.pnpm/baz@1.0.0/node_modules/globals + +// @link: /node_modules/.pnpm/bar@1.0.0/node_modules/bar -> /node_modules/bar +// @link: /node_modules/.pnpm/baz@1.0.0/node_modules/baz -> /node_modules/baz + +// @filename: /src/index.ts +import { useBar } from "bar"; +import { useBaz } from "baz"; + +const barResult = useBar(); +const bazResult = useBaz(); + +const x: string = myGlobal;