Made TS6059 rootDir validation consistent for programmatic usage (#43145)

* Made TS6059 rootDir validation consistent for programmatic usage

* Corrected other baselines
This commit is contained in:
Josh Goldberg 2021-03-19 18:52:04 -04:00 committed by GitHub
parent 6a83ae19e2
commit 5813907abf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 2 deletions

View File

@ -3195,9 +3195,10 @@ namespace ts {
}
}
// there has to be common source directory if user specified --outdir || --sourceRoot
// there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot
// if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted
if (options.outDir || // there is --outDir specified
options.rootDir || // there is --rootDir specified
options.sourceRoot || // there is --sourceRoot specified
options.mapRoot) { // there is --mapRoot specified

View File

@ -372,7 +372,7 @@ var x = 0;`, {
});
transpilesCorrectly("Supports setting 'rootDir'", "x;", {
options: { compilerOptions: { rootDir: "./rootDir" }, fileName: "input.js", reportDiagnostics: true }
options: { compilerOptions: { rootDir: "./rootDir" }, fileName: "./rootDir/input.js", reportDiagnostics: true }
});
transpilesCorrectly("Supports setting 'rootDirs'", "x;", {

View File

@ -0,0 +1,18 @@
error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Root file specified for compilation
!!! error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files.
!!! error TS6059: The file is in the program because:
!!! error TS6059: Root file specified for compilation
==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ====
class C {
}
==== FolderA/FolderB/fileB.ts (0 errors) ====
/// <reference path='FolderC/fileC.ts'/>
class B {
public c: C;
}

View File

@ -0,0 +1,17 @@
{
"scenario": "rootDirectory: Files outside the rootDirectory without outDir",
"projectRoot": "tests/cases/projects/rootDirectory",
"inputFiles": [
"FolderA/FolderB/fileB.ts"
],
"rootDir": "FolderA/FolderB/FolderC",
"resolvedInputFiles": [
"lib.es5.d.ts",
"FolderA/FolderB/FolderC/fileC.ts",
"FolderA/FolderB/fileB.ts"
],
"emittedFiles": [
"FolderA/FolderB/FolderC/fileC.js",
"FolderA/FolderB/fileB.js"
]
}

View File

@ -0,0 +1,18 @@
error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files.
The file is in the program because:
Root file specified for compilation
!!! error TS6059: File 'FolderA/FolderB/fileB.ts' is not under 'rootDir' 'FolderA/FolderB/FolderC'. 'rootDir' is expected to contain all source files.
!!! error TS6059: The file is in the program because:
!!! error TS6059: Root file specified for compilation
==== FolderA/FolderB/FolderC/fileC.ts (0 errors) ====
class C {
}
==== FolderA/FolderB/fileB.ts (0 errors) ====
/// <reference path='FolderC/fileC.ts'/>
class B {
public c: C;
}

View File

@ -0,0 +1,17 @@
{
"scenario": "rootDirectory: Files outside the rootDirectory without outDir",
"projectRoot": "tests/cases/projects/rootDirectory",
"inputFiles": [
"FolderA/FolderB/fileB.ts"
],
"rootDir": "FolderA/FolderB/FolderC",
"resolvedInputFiles": [
"lib.es5.d.ts",
"FolderA/FolderB/FolderC/fileC.ts",
"FolderA/FolderB/fileB.ts"
],
"emittedFiles": [
"FolderA/FolderB/FolderC/fileC.js",
"FolderA/FolderB/fileB.js"
]
}

View File

@ -0,0 +1,8 @@
{
"scenario": "rootDirectory: Files outside the rootDirectory without outDir",
"projectRoot": "tests/cases/projects/rootDirectory",
"inputFiles": [
"FolderA/FolderB/fileB.ts"
],
"rootDir": "FolderA/FolderB/FolderC"
}