diff --git a/internal/compiler/program.go b/internal/compiler/program.go index c46207e545e..e06b6e1e4be 100644 --- a/internal/compiler/program.go +++ b/internal/compiler/program.go @@ -856,6 +856,48 @@ func (p *Program) verifyCompilerOptions() { } } + if !options.NoEmit.IsTrue() && + !options.Composite.IsTrue() && + options.RootDir == "" && + options.ConfigFilePath != "" && + (options.OutDir != "" || + (options.GetEmitDeclarations() && options.DeclarationDir != "") || + options.OutFile != "") { + // Check if rootDir inferred changed and issue diagnostic + dir := p.CommonSourceDirectory() + var emittedFiles []string + for _, file := range p.files { + if !file.IsDeclarationFile && sourceFileMayBeEmitted(file, p, false) { + emittedFiles = append(emittedFiles, file.FileName()) + } + } + dir59 := outputpaths.GetComputedCommonSourceDirectory(emittedFiles, p.GetCurrentDirectory(), p.UseCaseSensitiveFileNames()) + if dir59 != "" && tspath.GetCanonicalFileName(dir, p.UseCaseSensitiveFileNames()) != tspath.GetCanonicalFileName(dir59, p.UseCaseSensitiveFileNames()) { + // change in layout + var option1 string + if options.OutFile != "" { + option1 = "outFile" + } else if options.OutDir != "" { + option1 = "outDir" + } else { + option1 = "declarationDir" + } + var option2 string + if options.OutFile == "" && options.OutDir != "" { + option2 = "declarationDir" + } + diag := createDiagnosticForOption( + true, /*onKey*/ + option1, + option2, + diagnostics.The_common_source_directory_of_0_is_1_The_rootDir_setting_must_be_explicitly_set_to_this_or_another_path_to_adjust_your_output_s_file_layout, + tspath.GetBaseFileName(options.ConfigFilePath), + tspath.GetRelativePathFromFile(options.ConfigFilePath, dir59, p.comparePathsOptions), + ) + diag.AddMessageChain(ast.NewCompilerDiagnostic(diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashts6_for_migration_information)) + } + } + if options.CheckJs.IsTrue() && !options.GetAllowJS() { createDiagnosticForOptionName(diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs") } diff --git a/internal/outputpaths/commonsourcedirectory.go b/internal/outputpaths/commonsourcedirectory.go index 433f28635db..6b64d893b28 100644 --- a/internal/outputpaths/commonsourcedirectory.go +++ b/internal/outputpaths/commonsourcedirectory.go @@ -48,6 +48,14 @@ func computeCommonSourceDirectoryOfFilenames(fileNames []string, currentDirector return tspath.GetPathFromPathComponents(commonPathComponents) } +func GetComputedCommonSourceDirectory(emittedFiles []string, currentDirectory string, useCaseSensitiveFileNames bool) string { + commonSourceDirectory := computeCommonSourceDirectoryOfFilenames(emittedFiles, currentDirectory, useCaseSensitiveFileNames) + if len(commonSourceDirectory) > 0 { + commonSourceDirectory = tspath.EnsureTrailingDirectorySeparator(commonSourceDirectory) + } + return commonSourceDirectory +} + func GetCommonSourceDirectory(options *core.CompilerOptions, files func() []string, currentDirectory string, useCaseSensitiveFileNames bool) string { var commonSourceDirectory string if options.RootDir != "" { diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js index 4d8d4214440..d80a2aaa4b1 100644 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js @@ -25,3 +25,35 @@ x + y; //// [/app/bin/index.d.ts] /// export {}; + + +//// [DtsFileErrors] + + +error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + +!!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. +==== /app/tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "outDir": "bin", + "typeRoots": ["../types"], + "sourceMap": true, + "mapRoot": "myMapRoot", + "sourceRoot": "mySourceRoot", + "declaration": true + } + } + +==== /app/bin/index.d.ts (0 errors) ==== + /// + export {}; + +==== /types/bar.d.ts (0 errors) ==== + declare module "bar" { + export const y = 0; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff index a92adeec86d..69952b25c85 100644 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory.js.diff @@ -1,39 +1,24 @@ --- old.commonSourceDirectory.js +++ new.commonSourceDirectory.js -@@= skipped -24, +24 lines =@@ - //// [/app/bin/index.d.ts] - /// - export {}; -- -- --//// [DtsFileErrors] -- -- +@@= skipped -29, +29 lines =@@ + //// [DtsFileErrors] + + -/app/tsconfig.json(3,9): error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. -- Visit https://aka.ms/ts6 for migration information. -- -- ++error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + -==== /app/tsconfig.json (1 errors) ==== -- { -- "compilerOptions": { -- "outDir": "bin", ++!!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. ++!!! error TS5011: Visit https://aka.ms/ts6 for migration information. ++==== /app/tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "outDir": "bin", - ~~~~~~~~ -!!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. -!!! error TS5011: Visit https://aka.ms/ts6 for migration information. -- "typeRoots": ["../types"], -- "sourceMap": true, -- "mapRoot": "myMapRoot", -- "sourceRoot": "mySourceRoot", -- "declaration": true -- } -- } -- --==== /app/bin/index.d.ts (0 errors) ==== -- /// -- export {}; -- --==== /types/bar.d.ts (0 errors) ==== -- declare module "bar" { -- export const y = 0; -- } -- \ No newline at end of file + "typeRoots": ["../types"], + "sourceMap": true, + "mapRoot": "myMapRoot", \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt new file mode 100644 index 00000000000..39317702628 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt @@ -0,0 +1,25 @@ +/app/tsconfig.json(3,9): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + +==== /app/tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "outDir": "bin", + ~~~~~~~~ +!!! error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. + "sourceMap": true, + "mapRoot": "myMapRoot", + "sourceRoot": "mySourceRoot", + "declaration": true + } + } + +==== /app/lib/bar.d.ts (0 errors) ==== + declare const y: number; + +==== /app/src/index.ts (0 errors) ==== + /// + export const x = y; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt.diff deleted file mode 100644 index a8dbad91b76..00000000000 --- a/testdata/baselines/reference/submodule/compiler/commonSourceDirectory_dts.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.commonSourceDirectory_dts.errors.txt -+++ new.commonSourceDirectory_dts.errors.txt -@@= skipped -0, +0 lines =@@ --/app/tsconfig.json(3,9): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. -- Visit https://aka.ms/ts6 for migration information. -- -- --==== /app/tsconfig.json (1 errors) ==== -- { -- "compilerOptions": { -- "outDir": "bin", -- ~~~~~~~~ --!!! error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. --!!! error TS5011: Visit https://aka.ms/ts6 for migration information. -- "sourceMap": true, -- "mapRoot": "myMapRoot", -- "sourceRoot": "mySourceRoot", -- "declaration": true -- } -- } -- --==== /app/lib/bar.d.ts (0 errors) ==== -- declare const y: number; -- --==== /app/src/index.ts (0 errors) ==== -- /// -- export const x = y; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js b/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js index 0a0189ac4c6..06b90908a68 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js @@ -17,3 +17,19 @@ interface Foo { x: number; } export default Foo; + + +//// [DtsFileErrors] + + +error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + +!!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. +==== /foo/tsconfig.json (0 errors) ==== + { + "compilerOptions": { "declaration": true, "declarationDir": "out", "module": "commonjs", "target": "es2015" } + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js.diff index 72969ed0e45..b30c2276e31 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitToDeclarationDirWithDeclarationOption.js.diff @@ -1,23 +1,22 @@ --- old.declarationEmitToDeclarationDirWithDeclarationOption.js +++ new.declarationEmitToDeclarationDirWithDeclarationOption.js -@@= skipped -16, +16 lines =@@ - x: number; - } - export default Foo; -- -- --//// [DtsFileErrors] -- -- +@@= skipped -21, +21 lines =@@ + //// [DtsFileErrors] + + -/foo/tsconfig.json(2,47): error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. -- Visit https://aka.ms/ts6 for migration information. -- -- ++error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + -==== /foo/tsconfig.json (1 errors) ==== - { - "compilerOptions": { "declaration": true, "declarationDir": "out", "module": "commonjs", "target": "es2015" } - ~~~~~~~~~~~~~~~~ --!!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. --!!! error TS5011: Visit https://aka.ms/ts6 for migration information. -- } -- \ No newline at end of file + !!! error TS5011: The common source directory of 'tsconfig.json' is '../.src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + !!! error TS5011: Visit https://aka.ms/ts6 for migration information. ++==== /foo/tsconfig.json (0 errors) ==== ++ { ++ "compilerOptions": { "declaration": true, "declarationDir": "out", "module": "commonjs", "target": "es2015" } + } + \ No newline at end of file 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 837dbd0daf4..26d7aef3b18 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 @@ -11,7 +11,7 @@ export const x = 10; } tsgo -b -v -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * tsconfig.json @@ -20,6 +20,15 @@ Output:: [HH:MM:SS AM] Building project 'tsconfig.json'... +tsconfig.json:3:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +3 "outDir": "dist", +   ~~~~~~~~ + + +Found 1 error in tsconfig.json:3 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -47,10 +56,11 @@ declare const console: { log(msg: any): void; }; export const x = 10; //// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts"]} //// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -59,33 +69,61 @@ export const x = 10; "original": "../src/index.ts" } ], - "size": 54 + "size": 68 } tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/project/src/index.ts Signatures:: Edit [0]:: no change tsgo -b -v -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated 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/src/index.js' +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because buildinfo file 'dist/tsconfig.tsbuildinfo' indicates that program needs to report errors. + +[HH:MM:SS AM] Building project 'tsconfig.json'... + +tsconfig.json:3:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +3 "outDir": "dist", +   ~~~~~~~~ + +Found 1 error in tsconfig.json:3 +//// [/home/src/workspaces/project/dist/src/index.js] *rewrite with same content* +//// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo] *rewrite with same content* +//// [/home/src/workspaces/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *rewrite with same content* + +tsconfig.json:: +SemanticDiagnostics:: +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/project/src/index.ts +Signatures:: Edit [1]:: Normal build without change, that does not block emit on error to show files that get emitted tsgo -p /home/src/workspaces/project/tsconfig.json -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: +tsconfig.json:3:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +3 "outDir": "dist", +   ~~~~~~~~ + + +Found 1 error in tsconfig.json:3 + //// [/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 38c5639b54c..80487d28a32 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 @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -44,6 +50,9 @@ project/src/hello.json Part of 'files' list in tsconfig.json project/src/index.ts Part of 'files' list in tsconfig.json + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -82,10 +91,11 @@ const hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts","../src/hello.json"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts","../src/hello.json"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -100,12 +110,12 @@ exports.default = hello_json_1.default.hello; "original": "../src/hello.json" } ], - "size": 74 + "size": 88 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: 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 73ee4a484c6..50ca8826bee 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 @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -44,6 +50,9 @@ project/src/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' + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -82,10 +91,11 @@ const hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/hello.json","../src/index.ts"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/hello.json","../src/index.ts"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -100,12 +110,12 @@ exports.default = hello_json_1.default.hello; "original": "../src/index.ts" } ], - "size": 74 + "size": 88 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: 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 767f0d01120..64a2e238929 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 @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -44,6 +50,9 @@ project/src/index.json Matched by include pattern 'src/**/*' in 'project/tsconfig.json' project/src/index.ts Matched by include pattern 'src/**/*' in 'project/tsconfig.json' + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -82,10 +91,11 @@ exports.default = index_json_1.default.hello; } //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts","../src/index.json"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts","../src/index.json"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -100,12 +110,12 @@ exports.default = index_json_1.default.hello; "original": "../src/index.json" } ], - "size": 74 + "size": 88 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/index.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/index.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: 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 601758ba18d..79e1f9f8fce 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 @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -44,6 +50,9 @@ project/src/hello.json Matched by include pattern 'src/**/*' in 'project/tsconfig.json' project/src/index.ts Matched by include pattern 'src/**/*' in 'project/tsconfig.json' + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -82,10 +91,11 @@ const hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts","../src/hello.json"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts","../src/hello.json"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -100,12 +110,12 @@ exports.default = hello_json_1.default.hello; "original": "../src/hello.json" } ], - "size": 74 + "size": 88 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: 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 5125875cb61..8c519ca9797 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -43,6 +49,9 @@ project/src/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' + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -81,10 +90,11 @@ const hello_json_1 = __importDefault(require("./hello.json")); exports.default = hello_json_1.default.hello; //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -93,12 +103,12 @@ exports.default = hello_json_1.default.hello; "original": "../src/index.ts" } ], - "size": 54 + "size": 68 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: 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 f0aee17c030..d1ff049a82f 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 @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + TSFILE: /home/src/workspaces/solution/project/dist/src/index.js TSFILE: /home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo ../../tslibs/TS/Lib/lib.es2025.full.d.ts @@ -42,6 +48,9 @@ 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' + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -75,10 +84,11 @@ const hello_json_1 = __importDefault(require("../../hello.json")); exports.default = hello_json_1.default.hello; //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":["../src/index.ts"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -87,12 +97,12 @@ exports.default = hello_json_1.default.hello; "original": "../src/index.ts" } ], - "size": 54 + "size": 68 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: diff --git a/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js b/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js index a557389eaa4..7a2c04468ab 100644 --- a/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js +++ b/testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js @@ -25,7 +25,7 @@ export default hello.hello } tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: [HH:MM:SS AM] Projects in this build: * project/tsconfig.json @@ -34,6 +34,12 @@ Output:: [HH:MM:SS AM] Building project 'project/tsconfig.json'... +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + 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 @@ -45,6 +51,9 @@ project/src/hello.json Part of 'files' list in tsconfig.json project/src/index.ts Part of 'files' list in tsconfig.json + +Found 1 error in project/tsconfig.json:9 + //// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib* /// interface Boolean {} @@ -85,10 +94,11 @@ exports.default = hello_json_1.default.hello; //// [/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"]} +{"version":"FakeTSVersion","errors":true,"root":["../src/index.ts","../src/hello.json"]} //// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", + "errors": true, "root": [ { "files": [ @@ -103,25 +113,58 @@ exports.default = hello_json_1.default.hello; "original": "../src/hello.json" } ], - "size": 74 + "size": 88 } project/tsconfig.json:: SemanticDiagnostics:: -*refresh* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts -*refresh* /home/src/workspaces/solution/project/src/hello.json -*refresh* /home/src/workspaces/solution/project/src/index.ts +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts Signatures:: Edit [0]:: no change tsgo --b project --v --explainFiles --listEmittedFiles -ExitStatus:: Success +ExitStatus:: DiagnosticsPresent_OutputsGenerated 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/src/hello.json' +[HH:MM:SS AM] Project 'project/tsconfig.json' is out of date because buildinfo file 'project/dist/tsconfig.tsbuildinfo' indicates that program needs to report errors. + +[HH:MM:SS AM] Building project 'project/tsconfig.json'... + +project/tsconfig.json:9:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +9 "outDir": "dist", +   ~~~~~~~~ + +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.es2025.full.d.ts + Default library for target 'ES2025' +project/src/hello.json + Imported via "./hello.json" from file 'project/src/index.ts' + Part of 'files' list in tsconfig.json +project/src/index.ts + Part of 'files' list in tsconfig.json + +Found 1 error in project/tsconfig.json:9 +//// [/home/src/workspaces/solution/project/dist/src/hello.json] *rewrite with same content* +//// [/home/src/workspaces/solution/project/dist/src/index.js] *rewrite with same content* +//// [/home/src/workspaces/solution/project/dist/src/index.js.map] *rewrite with same content* +//// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo] *rewrite with same content* +//// [/home/src/workspaces/solution/project/dist/tsconfig.tsbuildinfo.readable.baseline.txt] *rewrite with same content* +project/tsconfig.json:: +SemanticDiagnostics:: +*not cached* /home/src/tslibs/TS/Lib/lib.es2025.full.d.ts +*not cached* /home/src/workspaces/solution/project/src/hello.json +*not cached* /home/src/workspaces/solution/project/src/index.ts +Signatures:: 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 a8da47c2550..30a3742b82a 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 @@ -46,16 +46,11 @@ export interface MyType extends Function { tsgo -p D:\Work\pkg1 --explainFiles ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -src/main.ts:6:5 - error TS2564: Property 'id' has no initializer and is not definitely assigned in the constructor. +tsconfig.json:5:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. -6 id: string; -   ~~ - -src/utils/index.ts:8:12 - error TS2352: Conversion of type 'typeof PartialClassType' to type 'MyReturnType' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. - Cannot assign an abstract constructor type to a non-abstract constructor type. - -8 return PartialClassType as MyReturnType; -   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +5 "outDir": "./dist", +   ~~~~~~~~ ../../home/src/tslibs/TS/Lib/lib.es2017.full.d.ts Default library for target 'ES2017' @@ -68,11 +63,7 @@ src/utils/index.ts src/main.ts Matched by include pattern 'src' in 'tsconfig.json' -Found 2 errors in 2 files. - -Errors Files - 1 src/main.ts:6 - 1 src/utils/index.ts:8 +Found 1 error in tsconfig.json:5 //// [D:/Work/pkg1/dist/src/main.d.ts] *new* declare const Sub_base: import("./utils/type-helpers").MyReturnType; diff --git a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js index d5ec252f4f5..6db52d38aa0 100644 --- a/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js +++ b/testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js @@ -268,6 +268,12 @@ Resolving real path for '/home/src/projects/component-type-checker/node_modules/ 3 "target": "es5",    ~~~~~ +tsconfig.json:7:9 - error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + +7 "outDir": "dist", +   ~~~~~~~~ + ../../../../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 @@ -284,7 +290,7 @@ Resolving real path for '/home/src/projects/component-type-checker/node_modules/ src/app.tsx Matched by include pattern 'src' in 'tsconfig.json' -Found 1 error in tsconfig.json:3 +Found 2 errors in the same file, starting at: tsconfig.json:3 //// [/home/src/projects/component-type-checker/packages/app/dist/src/app.js] *new* import { createButton } from "@component-type-checker/button";