From e2f153bed31bd1b96e9015df1b40a4aeffc95791 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 15 Jan 2026 14:20:18 -0800 Subject: [PATCH 1/2] Port rootDir default to configFile directory and some module resolution fixes --- internal/compiler/emitter.go | 4 +- internal/execute/tsctests/tscbuild_test.go | 2 +- internal/module/resolver.go | 7 ++- internal/outputpaths/commonsourcedirectory.go | 5 +- .../compiler/commonSourceDirectory_dts.js | 8 +-- .../commonSourceDirectory_dts.js.diff | 21 +++++++ .../compiler/commonSourceDirectory_dts.js.map | 6 +- .../commonSourceDirectory_dts.js.map.diff | 9 +++ .../commonSourceDirectory_dts.sourcemap.txt | 12 ++-- ...mmonSourceDirectory_dts.sourcemap.txt.diff | 34 ++++++++++ ...fNameWithOutDirDeclDirComposite.errors.txt | 32 ---------- ...WithOutDirDeclDirComposite.errors.txt.diff | 36 ----------- ...SelfNameWithOutDirDeclDirComposite.symbols | 2 + ...ameWithOutDirDeclDirComposite.symbols.diff | 12 ---- ...geSelfNameWithOutDirDeclDirComposite.types | 10 +-- ...fNameWithOutDirDeclDirComposite.types.diff | 21 ------- ...utDirDeclDirCompositeNestedDirs.errors.txt | 42 ------------- ...DeclDirCompositeNestedDirs.errors.txt.diff | 46 -------------- ...thOutDirDeclDirCompositeNestedDirs.symbols | 2 + ...DirDeclDirCompositeNestedDirs.symbols.diff | 12 ---- ...WithOutDirDeclDirCompositeNestedDirs.types | 10 +-- ...utDirDeclDirCompositeNestedDirs.types.diff | 21 ------- ...NameWithOutDirDeclDirNestedDirs.errors.txt | 44 ------------- ...ithOutDirDeclDirNestedDirs.errors.txt.diff | 63 ++++++++++++------- ...elfNameWithOutDirDeclDirNestedDirs.symbols | 2 + ...meWithOutDirDeclDirNestedDirs.symbols.diff | 12 ---- ...eSelfNameWithOutDirDeclDirNestedDirs.types | 10 +-- ...NameWithOutDirDeclDirNestedDirs.types.diff | 21 ------- ...ared-resolution-should-not-report-error.js | 6 +- .../when-resolution-is-not-shared.js | 6 +- .../when-rootDir-is-not-specified.js | 6 +- ...iles-containing-json-file-non-composite.js | 8 +-- .../include-and-files-non-composite.js | 8 +-- ...file-name-matches-ts-file-non-composite.js | 8 +-- ...-along-with-other-include-non-composite.js | 8 +-- .../include-only-non-composite.js | 8 +-- ...t-outside-configDirectory-non-composite.js | 12 +--- .../sourcemap-non-composite.js | 16 ++--- ...ing-Windows-paths-and-uppercase-letters.js | 12 ++-- .../tsc/moduleResolution/pnpm-style-layout.js | 2 +- 40 files changed, 190 insertions(+), 416 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.diff create mode 100644 testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map.diff create mode 100644 testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff diff --git a/internal/compiler/emitter.go b/internal/compiler/emitter.go index d841a459a7b..d0a621283a3 100644 --- a/internal/compiler/emitter.go +++ b/internal/compiler/emitter.go @@ -450,8 +450,8 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit return false } - // Otherwise if rootDir or composite config file, we know common sourceDir and can check if file would be emitted in same location - if options.RootDir != "" || (options.Composite.IsTrue() && options.ConfigFilePath != "") { + // Otherwise if rootDir or config file, we know common sourceDir and can check if file would be emitted in same location + if options.RootDir != "" || options.ConfigFilePath != "" { commonDir := tspath.GetNormalizedAbsolutePath(outputpaths.GetCommonSourceDirectory(options, func() []string { return nil }, host.GetCurrentDirectory(), host.UseCaseSensitiveFileNames()), host.GetCurrentDirectory()) outputPath := outputpaths.GetSourceFilePathInNewDirWorker(sourceFile.FileName(), options.OutDir, host.GetCurrentDirectory(), commonDir, host.UseCaseSensitiveFileNames()) if tspath.ComparePaths(sourceFile.FileName(), outputPath, tspath.ComparePathsOptions{ diff --git a/internal/execute/tsctests/tscbuild_test.go b/internal/execute/tsctests/tscbuild_test.go index 786d0bae28e..15efd12dbdd 100644 --- a/internal/execute/tsctests/tscbuild_test.go +++ b/internal/execute/tsctests/tscbuild_test.go @@ -1710,7 +1710,7 @@ func TestBuildOutputPaths(t *testing.T) { }`), }, expectedDtsNames: []string{ - "/home/src/workspaces/project/dist/index.js", + "/home/src/workspaces/project/dist/src/index.js", }, }, { diff --git a/internal/module/resolver.go b/internal/module/resolver.go index ce57d051150..51e472930a1 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -721,6 +721,7 @@ func (r *resolutionState) loadModuleFromTargetExportOrImport(extensions extensio finalPath = tspath.GetNormalizedAbsolutePath(resolvedTarget+subpath, r.resolver.host.GetCurrentDirectory()) } if inputLink := r.tryLoadInputFileForPath(finalPath, subpath, tspath.CombinePaths(scope.PackageDirectory, "package.json"), isImports); !inputLink.shouldContinueSearching() { + inputLink.packageId = r.getPackageId(inputLink.path, scope) return inputLink } if result := r.loadFileNameFromPackageJSONField(extensions, finalPath, targetString, false /*onlyRecordFailures*/); !result.shouldContinueSearching() { @@ -807,9 +808,9 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string if r.compilerOptions.RootDir != "" { // A `rootDir` compiler option strongly indicates the root location rootDir = r.compilerOptions.RootDir - } else if r.compilerOptions.Composite.IsTrue() && r.compilerOptions.ConfigFilePath != "" { - // A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations - rootDir = r.compilerOptions.ConfigFilePath + } else if r.compilerOptions.ConfigFilePath != "" { + // A project with common src dir set to `.`, so it shouldn't need to check any other locations + rootDir = tspath.GetDirectoryPath(r.compilerOptions.ConfigFilePath) } else { diagnostic := ast.NewDiagnostic( nil, diff --git a/internal/outputpaths/commonsourcedirectory.go b/internal/outputpaths/commonsourcedirectory.go index efd7a937fc4..433f28635db 100644 --- a/internal/outputpaths/commonsourcedirectory.go +++ b/internal/outputpaths/commonsourcedirectory.go @@ -53,9 +53,8 @@ func GetCommonSourceDirectory(options *core.CompilerOptions, files func() []stri if options.RootDir != "" { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = options.RootDir - } else if options.Composite.IsTrue() && options.ConfigFilePath != "" { - // If the rootDir is not specified, but the project is composite, then the common source directory - // is the directory of the config file. + } else if options.ConfigFilePath != "" { + // If the rootDir is not specified, then the common source directory is the directory of the config file. commonSourceDirectory = tspath.GetDirectoryPath(options.ConfigFilePath) } else { commonSourceDirectory = computeCommonSourceDirectoryOfFilenames(files(), currentDirectory, useCaseSensitiveFileNames) diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js index 6d3ac4c81d3..e4b36a2cdc0 100644 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js @@ -8,14 +8,14 @@ declare const y: number; export const x = y; -//// [/app/bin/index.js] +//// [/app/bin/src/index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; /// exports.x = y; -//# sourceMappingURL=../src/myMapRoot/index.js.map +//# sourceMappingURL=../../myMapRoot/src/index.js.map -//// [/app/bin/index.d.ts] -/// +//// [/app/bin/src/index.d.ts] +/// export declare const x: number; diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.diff new file mode 100644 index 00000000000..a11dc4c63da --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.diff @@ -0,0 +1,21 @@ +--- old.commonSourceDirectory_dts.js ++++ new.commonSourceDirectory_dts.js +@@= skipped -7, +7 lines =@@ + export const x = y; + + +-//// [/app/bin/index.js] ++//// [/app/bin/src/index.js] + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.x = void 0; + /// + exports.x = y; +-//# sourceMappingURL=../src/myMapRoot/index.js.map ++//# sourceMappingURL=../../myMapRoot/src/index.js.map + +-//// [/app/bin/index.d.ts] +-/// ++//// [/app/bin/src/index.d.ts] ++/// + export declare const x: number; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map index 8cf42ea16e7..ee62005ba3b 100644 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map @@ -1,3 +1,3 @@ -//// [/app/bin/index.js.map] -{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"} -//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vc3JjL215TWFwUm9vdC9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsiaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsd0RBQXdEO0FBQzNDLFFBQUEsQ0FBQyxHQUFHLENBQUMsQ0FBQyJ9,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo= +//// [/app/bin/src/index.js.map] +{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"} +//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vLi4vbXlNYXBSb290L3NyYy9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsic3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHdEQUF3RDtBQUMzQyxRQUFBLENBQUMsR0FBRyxDQUFDLENBQUMifQ==,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo= diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map.diff new file mode 100644 index 00000000000..a14f3bac40e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.js.map.diff @@ -0,0 +1,9 @@ +--- old.commonSourceDirectory_dts.js.map ++++ new.commonSourceDirectory_dts.js.map +@@= skipped -0, +0 lines =@@ +-//// [/app/bin/index.js.map] +-{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"} +-//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vc3JjL215TWFwUm9vdC9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsiaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsd0RBQXdEO0FBQzNDLFFBQUEsQ0FBQyxHQUFHLENBQUMsQ0FBQyJ9,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo= ++//// [/app/bin/src/index.js.map] ++{"version":3,"file":"index.js","sourceRoot":"mySourceRoot/","sources":["src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AAC3C,QAAA,CAAC,GAAG,CAAC,CAAC"} ++//// https://sokra.github.io/source-map-visualization#base64,InVzZSBzdHJpY3QiOw0KT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgeyB2YWx1ZTogdHJ1ZSB9KTsNCmV4cG9ydHMueCA9IHZvaWQgMDsNCi8vLyA8cmVmZXJlbmNlIHBhdGg9Ii4uL2xpYi9iYXIuZC50cyIgcHJlc2VydmU9InRydWUiIC8+DQpleHBvcnRzLnggPSB5Ow0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9Li4vLi4vbXlNYXBSb290L3NyYy9pbmRleC5qcy5tYXA=,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoibXlTb3VyY2VSb290LyIsInNvdXJjZXMiOlsic3JjL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHdEQUF3RDtBQUMzQyxRQUFBLENBQUMsR0FBRyxDQUFDLENBQUMifQ==,Ly8vIDxyZWZlcmVuY2UgcGF0aD0iLi4vbGliL2Jhci5kLnRzIiBwcmVzZXJ2ZT0idHJ1ZSIgLz4KZXhwb3J0IGNvbnN0IHggPSB5Owo= \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt index c98d6a26d67..24036677d75 100644 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt @@ -1,12 +1,12 @@ =================================================================== JsFile: index.js -mapUrl: ../src/myMapRoot/index.js.map +mapUrl: ../../myMapRoot/src/index.js.map sourceRoot: mySourceRoot/ -sources: index.ts +sources: src/index.ts =================================================================== ------------------------------------------------------------------- -emittedFile:/app/bin/index.js -sourceFile:index.ts +emittedFile:/app/bin/src/index.js +sourceFile:src/index.ts ------------------------------------------------------------------- >>>"use strict"; >>>Object.defineProperty(exports, "__esModule", { value: true }); @@ -26,7 +26,7 @@ sourceFile:index.ts 4 > ^^^ 5 > ^ 6 > ^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > >export const 2 > @@ -41,4 +41,4 @@ sourceFile:index.ts 5 >Emitted(5, 14) Source(2, 19) + SourceIndex(0) 6 >Emitted(5, 15) Source(2, 20) + SourceIndex(0) --- ->>>//# sourceMappingURL=../src/myMapRoot/index.js.map \ No newline at end of file +>>>//# sourceMappingURL=../../myMapRoot/src/index.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt.diff new file mode 100644 index 00000000000..98bee6aec89 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.sourcemap.txt.diff @@ -0,0 +1,34 @@ +--- old.commonSourceDirectory_dts.sourcemap.txt ++++ new.commonSourceDirectory_dts.sourcemap.txt +@@= skipped -0, +0 lines =@@ + =================================================================== + JsFile: index.js +-mapUrl: ../src/myMapRoot/index.js.map ++mapUrl: ../../myMapRoot/src/index.js.map + sourceRoot: mySourceRoot/ +-sources: index.ts ++sources: src/index.ts + =================================================================== + ------------------------------------------------------------------- +-emittedFile:/app/bin/index.js +-sourceFile:index.ts ++emittedFile:/app/bin/src/index.js ++sourceFile:src/index.ts + ------------------------------------------------------------------- + >>>"use strict"; + >>>Object.defineProperty(exports, "__esModule", { value: true }); +@@= skipped -25, +25 lines =@@ + 4 > ^^^ + 5 > ^ + 6 > ^ +-7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> ++7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> + 1 > + >export const + 2 > +@@= skipped -15, +15 lines =@@ + 5 >Emitted(5, 14) Source(2, 19) + SourceIndex(0) + 6 >Emitted(5, 15) Source(2, 20) + SourceIndex(0) + --- +->>>//# sourceMappingURL=../src/myMapRoot/index.js.map ++>>>//# sourceMappingURL=../../myMapRoot/src/index.js.map \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt deleted file mode 100644 index 94d98a813d7..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt +++ /dev/null @@ -1,32 +0,0 @@ -index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "composite": true - } - } -==== index.ts (1 errors) ==== - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function thing(): void {} - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff deleted file mode 100644 index 7d11a0b922d..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.errors.txt -@@= skipped -0, +0 lines =@@ -- -+index.ts(1,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "outDir": "./dist", -+ "declarationDir": "./types", -+ "composite": true -+ } -+ } -+==== index.ts (1 errors) ==== -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function thing(): void {} -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": { -+ "default": "./dist/index.js", -+ "types": "./types/index.d.ts" -+ } -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols index fad765ba6fc..12f74f21677 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols @@ -5,7 +5,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(index.ts, 0, 6)) me.thing(); +>me.thing : Symbol(thing, Decl(index.ts, 2, 11)) >me : Symbol(me, Decl(index.ts, 0, 6)) +>thing : Symbol(thing, Decl(index.ts, 2, 11)) export function thing(): void {} >thing : Symbol(thing, Decl(index.ts, 2, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff deleted file mode 100644 index ac6c21f8efd..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.symbols -@@= skipped -4, +4 lines =@@ - >me : Symbol(me, Decl(index.ts, 0, 6)) - - me.thing(); -->me.thing : Symbol(thing, Decl(index.ts, 2, 11)) - >me : Symbol(me, Decl(index.ts, 0, 6)) -->thing : Symbol(thing, Decl(index.ts, 2, 11)) - - export function thing(): void {} - >thing : Symbol(thing, Decl(index.ts, 2, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types index 0312d872bad..a4654ce72ce 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types @@ -2,13 +2,13 @@ === index.ts === import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function thing(): void {} >thing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff deleted file mode 100644 index 5b1a188279c..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirComposite.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirComposite.types -@@= skipped -1, +1 lines =@@ - - === index.ts === - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function thing(): void {} - >thing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt deleted file mode 100644 index 78b1581d017..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt +++ /dev/null @@ -1,42 +0,0 @@ -src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "composite": true - } - } -==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` - // (the harness is wierd here in that noImplicitReferences makes only - // this file get loaded as an entrypoint and emitted, while on the - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function srcthing(): void {} - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff deleted file mode 100644 index 4b52c813200..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt.diff +++ /dev/null @@ -1,46 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ -+==== tsconfig.json (0 errors) ==== -+ { -+ "compilerOptions": { -+ "module": "nodenext", -+ "outDir": "./dist", -+ "declarationDir": "./types", -+ "composite": true -+ } -+ } -+==== index.ts (0 errors) ==== -+ export {srcthing as thing} from "./src/thing.js"; -+==== src/thing.ts (1 errors) ==== -+ // The following import should cause `index.ts` -+ // to be included in the build, which will, -+ // in turn, cause the common src directory to not be `src` -+ // (the harness is wierd here in that noImplicitReferences makes only -+ // this file get loaded as an entrypoint and emitted, while on the -+ // real command-line we'll crawl the imports for that set - a limitation -+ // of the harness, I suppose) -+ import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. -+ -+ me.thing(); -+ -+ export function srcthing(): void {} -+ -+ -+==== package.json (0 errors) ==== -+ { -+ "name": "@this/package", -+ "type": "module", -+ "exports": { -+ ".": { -+ "default": "./dist/index.js", -+ "types": "./types/index.d.ts" -+ } -+ } -+ } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols index 8325dd2aefa..7fd0a813111 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols @@ -17,7 +17,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); +>me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) +>thing : Symbol(me.thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff deleted file mode 100644 index c477bfdd8eb..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.symbols -@@= skipped -16, +16 lines =@@ - >me : Symbol(me, Decl(thing.ts, 7, 6)) - - me.thing(); -->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) - >me : Symbol(me, Decl(thing.ts, 7, 6)) -->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) - - export function srcthing(): void {} - >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types index 21e392eb8be..d65e7900aa6 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff deleted file mode 100644 index f353a36a665..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirCompositeNestedDirs.types -@@= skipped -13, +13 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function srcthing(): void {} - >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt deleted file mode 100644 index c69d272c9dc..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - -!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -==== tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "module": "nodenext", - "outDir": "./dist", - "declarationDir": "./types", - "declaration": true - } - } -==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` - // (the harness is wierd here in that noImplicitReferences makes only - // this file get loaded as an entrypoint and emitted, while on the - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; - ~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - - export function srcthing(): void {} - - -==== package.json (0 errors) ==== - { - "name": "@this/package", - "type": "module", - "exports": { - ".": { - "default": "./dist/index.js", - "types": "./types/index.d.ts" - } - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff index ab5efeb9733..ba75c52cb20 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt.diff @@ -1,26 +1,45 @@ --- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt +++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.errors.txt @@= skipped -0, +0 lines =@@ - error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -+src/thing.ts(8,21): error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - - !!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. -@@= skipped -12, +13 lines =@@ - } - ==== index.ts (0 errors) ==== - export {srcthing as thing} from "./src/thing.js"; +-error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +- +- +-!!! error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file 'package.json'. Supply the `rootDir` compiler option to disambiguate. +-==== tsconfig.json (0 errors) ==== +- { +- "compilerOptions": { +- "module": "nodenext", +- "outDir": "./dist", +- "declarationDir": "./types", +- "declaration": true +- } +- } +-==== index.ts (0 errors) ==== +- export {srcthing as thing} from "./src/thing.js"; -==== src/thing.ts (0 errors) ==== -+==== src/thing.ts (1 errors) ==== - // The following import should cause `index.ts` - // to be included in the build, which will, - // in turn, cause the common src directory to not be `src` -@@= skipped -9, +9 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -+ ~~~~~~~~~~~~~~~ -+!!! error TS2307: Cannot find module '@this/package' or its corresponding type declarations. - - me.thing(); - \ No newline at end of file +- // The following import should cause `index.ts` +- // to be included in the build, which will, +- // in turn, cause the common src directory to not be `src` +- // (the harness is wierd here in that noImplicitReferences makes only +- // this file get loaded as an entrypoint and emitted, while on the +- // real command-line we'll crawl the imports for that set - a limitation +- // of the harness, I suppose) +- import * as me from "@this/package"; +- +- me.thing(); +- +- export function srcthing(): void {} +- +- +-==== package.json (0 errors) ==== +- { +- "name": "@this/package", +- "type": "module", +- "exports": { +- ".": { +- "default": "./dist/index.js", +- "types": "./types/index.d.ts" +- } +- } +- } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols index 0cd32d19d77..fd266479ca9 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols @@ -17,7 +17,9 @@ import * as me from "@this/package"; >me : Symbol(me, Decl(thing.ts, 7, 6)) me.thing(); +>me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) >me : Symbol(me, Decl(thing.ts, 7, 6)) +>thing : Symbol(me.thing, Decl(index.ts, 0, 8)) export function srcthing(): void {} >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff deleted file mode 100644 index 2d5893b203d..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.symbols -@@= skipped -16, +16 lines =@@ - >me : Symbol(me, Decl(thing.ts, 7, 6)) - - me.thing(); -->me.thing : Symbol(me.thing, Decl(index.ts, 0, 8)) - >me : Symbol(me, Decl(thing.ts, 7, 6)) -->thing : Symbol(me.thing, Decl(index.ts, 0, 8)) - - export function srcthing(): void {} - >srcthing : Symbol(srcthing, Decl(thing.ts, 9, 11)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types index fa5240b00c5..fe50376388b 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types +++ b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types @@ -14,13 +14,13 @@ export {srcthing as thing} from "./src/thing.js"; // real command-line we'll crawl the imports for that set - a limitation // of the harness, I suppose) import * as me from "@this/package"; ->me : any +>me : typeof me me.thing(); ->me.thing() : any ->me.thing : any ->me : any ->thing : any +>me.thing() : void +>me.thing : () => void +>me : typeof me +>thing : () => void export function srcthing(): void {} >srcthing : () => void diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff b/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff deleted file mode 100644 index 6ad9c105ab4..00000000000 --- a/testdata/baselines/reference/submodule/compiler/nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types -+++ new.nodeNextPackageSelfNameWithOutDirDeclDirNestedDirs.types -@@= skipped -13, +13 lines =@@ - // real command-line we'll crawl the imports for that set - a limitation - // of the harness, I suppose) - import * as me from "@this/package"; -->me : typeof me -+>me : any - - me.thing(); -->me.thing() : void -->me.thing : () => void -->me : typeof me -->thing : () => void -+>me.thing() : any -+>me.thing : any -+>me : any -+>thing : any - - export function srcthing(): void {} - >srcthing : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/tsbuild/moduleResolution/shared-resolution-should-not-report-error.js b/testdata/baselines/reference/tsbuild/moduleResolution/shared-resolution-should-not-report-error.js index d66533dcd3f..a1543a18ec2 100644 --- a/testdata/baselines/reference/tsbuild/moduleResolution/shared-resolution-should-not-report-error.js +++ b/testdata/baselines/reference/tsbuild/moduleResolution/shared-resolution-should-not-report-error.js @@ -67,17 +67,13 @@ Found 'package.json' at '/home/src/workspaces/project/packages/a/package.json'. Entering conditional exports. Matched 'exports' condition 'types'. Using 'exports' subpath '.' with target './types/index.d.ts'. -File '/home/src/workspaces/project/packages/a/types/index.d.ts' does not exist. -Failed to resolve under condition 'types'. -Matched 'exports' condition 'default'. -Using 'exports' subpath '.' with target './index.js'. File name '/home/src/workspaces/project/packages/a/index.js' has a '.js' extension - stripping it. File '/home/src/workspaces/project/packages/a/index.ts' does not exist. File '/home/src/workspaces/project/packages/a/index.tsx' does not exist. File '/home/src/workspaces/project/packages/a/index.d.ts' does not exist. File '/home/src/workspaces/project/packages/a/index.js' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. -Resolved under condition 'default'. +Resolved under condition 'types'. Exiting conditional exports. ======== Module name 'a' was successfully resolved to '/home/src/workspaces/project/packages/a/index.js' with Package ID 'a/index.js@0.0.0'. ======== ../../tslibs/TS/Lib/lib.esnext.full.d.ts diff --git a/testdata/baselines/reference/tsbuild/moduleResolution/when-resolution-is-not-shared.js b/testdata/baselines/reference/tsbuild/moduleResolution/when-resolution-is-not-shared.js index 6772e2211fc..89d863b99e3 100644 --- a/testdata/baselines/reference/tsbuild/moduleResolution/when-resolution-is-not-shared.js +++ b/testdata/baselines/reference/tsbuild/moduleResolution/when-resolution-is-not-shared.js @@ -66,17 +66,13 @@ Found 'package.json' at '/home/src/workspaces/project/packages/a/package.json'. Entering conditional exports. Matched 'exports' condition 'types'. Using 'exports' subpath '.' with target './types/index.d.ts'. -File '/home/src/workspaces/project/packages/a/types/index.d.ts' does not exist. -Failed to resolve under condition 'types'. -Matched 'exports' condition 'default'. -Using 'exports' subpath '.' with target './index.js'. File name '/home/src/workspaces/project/packages/a/index.js' has a '.js' extension - stripping it. File '/home/src/workspaces/project/packages/a/index.ts' does not exist. File '/home/src/workspaces/project/packages/a/index.tsx' does not exist. File '/home/src/workspaces/project/packages/a/index.d.ts' does not exist. File '/home/src/workspaces/project/packages/a/index.js' exists - use it as a name resolution result. 'package.json' does not have a 'peerDependencies' field. -Resolved under condition 'default'. +Resolved under condition 'types'. Exiting conditional exports. ======== Module name 'a' was successfully resolved to '/home/src/workspaces/project/packages/a/index.js' with Package ID 'a/index.js@0.0.0'. ======== ../../tslibs/TS/Lib/lib.esnext.full.d.ts diff --git a/testdata/baselines/reference/tsbuild/outputPaths/when-rootDir-is-not-specified.js b/testdata/baselines/reference/tsbuild/outputPaths/when-rootDir-is-not-specified.js index 148ff32fc40..4c943d4ec3b 100644 --- a/testdata/baselines/reference/tsbuild/outputPaths/when-rootDir-is-not-specified.js +++ b/testdata/baselines/reference/tsbuild/outputPaths/when-rootDir-is-not-specified.js @@ -43,7 +43,7 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/project/dist/index.js] *new* +//// [/home/src/workspaces/project/dist/src/index.js] *new* "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; @@ -80,7 +80,7 @@ Output:: [HH:MM:SS AM] Projects in this build: * tsconfig.json -[HH:MM:SS AM] Project 'tsconfig.json' is up to date because newest input 'src/index.ts' is older than output 'dist/index.js' +[HH:MM:SS AM] Project 'tsconfig.json' is up to date because newest input 'src/index.ts' is older than output 'dist/src/index.js' @@ -90,5 +90,5 @@ Edit [1]:: Normal build without change, that does not block emit on error to sho tsgo -p /home/src/workspaces/project/tsconfig.json ExitStatus:: Success Output:: -//// [/home/src/workspaces/project/dist/index.js] *rewrite with same content* +//// [/home/src/workspaces/project/dist/src/index.js] *rewrite with same content* diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js index 2de0d0724c0..ca72071e12b 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js @@ -34,8 +34,8 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/hello.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -67,12 +67,12 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *new* { "hello": "world" } -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js index a5c35c529de..6c310eb75b1 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js @@ -34,8 +34,8 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/hello.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -67,12 +67,12 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *new* { "hello": "world" } -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js index d7297ab4df4..e0ef8b98335 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js @@ -34,8 +34,8 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/index.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/index.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -67,7 +67,7 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -76,7 +76,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const index_json_1 = __importDefault(require("./index.json")); exports.default = index_json_1.default.hello; -//// [/home/src/workspaces/solution/project/dist/index.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.json] *new* { "hello": "world" } diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js index 08c030581a5..e0733582ed4 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js @@ -34,8 +34,8 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/hello.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -67,12 +67,12 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *new* { "hello": "world" } -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js index 5e9ff93637d..24826fa9c9a 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js @@ -34,8 +34,8 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/hello.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -66,12 +66,12 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *new* { "hello": "world" } -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js index bc173d2e26f..dcbdd59ed85 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js @@ -34,8 +34,7 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/project/src/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -43,8 +42,6 @@ hello.json Imported via "../../hello.json" from file 'project/src/index.ts' project/src/index.ts Matched by include pattern 'src/**/*' in 'project/tsconfig.json' -[HH:MM:SS AM] Updating unchanged output timestamps of project 'project/tsconfig.json'... - //// [/home/src/tslibs/TS/Lib/lib.d.ts] *Lib* /// interface Boolean {} @@ -68,12 +65,7 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* -{ - "hello": "world" -} - -//// [/home/src/workspaces/solution/project/dist/project/src/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js index f8790308405..66c7d73b621 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js @@ -34,9 +34,9 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... -TSFILE: /home/src/workspaces/solution/project/dist/hello.json -TSFILE: /home/src/workspaces/solution/project/dist/index.js.map -TSFILE: /home/src/workspaces/solution/project/dist/index.js +TSFILE: /home/src/workspaces/solution/project/dist/src/hello.json +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js.map +TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.d.ts Default library for target 'ES5' @@ -68,12 +68,12 @@ interface Symbol { readonly [Symbol.toStringTag]: string; } declare const console: { log(msg: any): void; }; -//// [/home/src/workspaces/solution/project/dist/hello.json] *new* +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *new* { "hello": "world" } -//// [/home/src/workspaces/solution/project/dist/index.js] *new* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *new* "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -82,8 +82,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; //# sourceMappingURL=index.js.map -//// [/home/src/workspaces/solution/project/dist/index.js.map] *new* -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,8DAAgC;kBACjB,oBAAK,CAAC,KAAK"} +//// [/home/src/workspaces/solution/project/dist/src/index.js.map] *new* +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,8DAAgC;kBACjB,oBAAK,CAAC,KAAK"} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* {"version":"FakeTSVersion","root":["../src/index.ts","../src/hello.json"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* @@ -122,6 +122,6 @@ Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json -[HH:MM:SS AM] Project 'project/tsconfig.json' is up to date because newest input 'project/src/index.ts' is older than output 'project/dist/hello.json' +[HH:MM:SS AM] Project 'project/tsconfig.json' is up to date because newest input 'project/src/index.ts' is older than output 'project/dist/src/hello.json' diff --git a/testdata/baselines/reference/tsc/declarationEmit/when-using-Windows-paths-and-uppercase-letters.js b/testdata/baselines/reference/tsc/declarationEmit/when-using-Windows-paths-and-uppercase-letters.js index 852c8a05f54..7845d60bcf0 100644 --- a/testdata/baselines/reference/tsc/declarationEmit/when-using-Windows-paths-and-uppercase-letters.js +++ b/testdata/baselines/reference/tsc/declarationEmit/when-using-Windows-paths-and-uppercase-letters.js @@ -65,14 +65,14 @@ src/main.ts Found 1 error in src/utils/index.ts:8 -//// [D:/Work/pkg1/dist/main.d.ts] *new* +//// [D:/Work/pkg1/dist/src/main.d.ts] *new* declare const Sub_base: import("./utils/type-helpers").MyReturnType; export declare class Sub extends Sub_base { id: string; } export {}; -//// [D:/Work/pkg1/dist/main.js] *new* +//// [D:/Work/pkg1/dist/src/main.js] *new* import { PartialType } from './utils'; class Common { } @@ -80,11 +80,11 @@ export class Sub extends PartialType(Common) { id; } -//// [D:/Work/pkg1/dist/utils/index.d.ts] *new* +//// [D:/Work/pkg1/dist/src/utils/index.d.ts] *new* import { MyType, MyReturnType } from './type-helpers'; export declare function PartialType(classRef: MyType): MyReturnType; -//// [D:/Work/pkg1/dist/utils/index.js] *new* +//// [D:/Work/pkg1/dist/src/utils/index.js] *new* export function PartialType(classRef) { class PartialClassType { constructor() { } @@ -92,7 +92,7 @@ export function PartialType(classRef) { return PartialClassType; } -//// [D:/Work/pkg1/dist/utils/type-helpers.d.ts] *new* +//// [D:/Work/pkg1/dist/src/utils/type-helpers.d.ts] *new* export type MyReturnType = { new (...args: any[]): any; }; @@ -100,7 +100,7 @@ export interface MyType extends Function { new (...args: any[]): T; } -//// [D:/Work/pkg1/dist/utils/type-helpers.js] *new* +//// [D:/Work/pkg1/dist/src/utils/type-helpers.js] *new* export {}; //// [D:/home/src/tslibs/TS/Lib/lib.es2017.full.d.ts] *Lib* diff --git a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js index 3c2149a1b27..d7114763646 100644 --- a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js +++ b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js @@ -278,7 +278,7 @@ Resolving real path for '/home/src/projects/component-type-checker/node_modules/ 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* +//// [/home/src/projects/component-type-checker/packages/app/dist/src/app.js] *new* import { createButton } from "@component-type-checker/button"; const button = createButton(); From fdb604d25ae3ce6b4498f6cecbafb64792cd8146 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 15 Jan 2026 15:10:15 -0800 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- internal/compiler/emitter.go | 2 +- internal/module/resolver.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/compiler/emitter.go b/internal/compiler/emitter.go index d0a621283a3..695aa39f697 100644 --- a/internal/compiler/emitter.go +++ b/internal/compiler/emitter.go @@ -450,7 +450,7 @@ func sourceFileMayBeEmitted(sourceFile *ast.SourceFile, host SourceFileMayBeEmit return false } - // Otherwise if rootDir or config file, we know common sourceDir and can check if file would be emitted in same location + // Otherwise, if rootDir is specified or a config file exists, we know the common source directory and can check if the file would be emitted in the same location if options.RootDir != "" || options.ConfigFilePath != "" { commonDir := tspath.GetNormalizedAbsolutePath(outputpaths.GetCommonSourceDirectory(options, func() []string { return nil }, host.GetCurrentDirectory(), host.UseCaseSensitiveFileNames()), host.GetCurrentDirectory()) outputPath := outputpaths.GetSourceFilePathInNewDirWorker(sourceFile.FileName(), options.OutDir, host.GetCurrentDirectory(), commonDir, host.UseCaseSensitiveFileNames()) diff --git a/internal/module/resolver.go b/internal/module/resolver.go index 51e472930a1..297a2f63ac2 100644 --- a/internal/module/resolver.go +++ b/internal/module/resolver.go @@ -809,7 +809,7 @@ func (r *resolutionState) tryLoadInputFileForPath(finalPath string, entry string // A `rootDir` compiler option strongly indicates the root location rootDir = r.compilerOptions.RootDir } else if r.compilerOptions.ConfigFilePath != "" { - // A project with common src dir set to `.`, so it shouldn't need to check any other locations + // When no explicit rootDir is set, treat the config file's directory as the project root, which establishes the common source directory, so no other locations need to be checked. rootDir = tspath.GetDirectoryPath(r.compilerOptions.ConfigFilePath) } else { diagnostic := ast.NewDiagnostic(