Exclude outDir and declarationDir even if they come from extended config (#58335)

This commit is contained in:
Sheetal Nandi
2024-04-26 13:14:40 -07:00
committed by GitHub
parent 04963ee796
commit c92bd16ac0
14 changed files with 170 additions and 35 deletions

View File

@@ -2976,12 +2976,12 @@ function parseJsonConfigFileContentWorker(
const excludeOfRaw = getSpecsFromRaw("exclude");
let isDefaultIncludeSpec = false;
let excludeSpecs = toPropValue(excludeOfRaw);
if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
const outDir = raw.compilerOptions.outDir;
const declarationDir = raw.compilerOptions.declarationDir;
if (excludeOfRaw === "no-prop") {
const outDir = options.outDir;
const declarationDir = options.declarationDir;
if (outDir || declarationDir) {
excludeSpecs = [outDir, declarationDir].filter(d => !!d);
excludeSpecs = filter([outDir, declarationDir], d => !!d) as string[];
}
}

View File

@@ -32,7 +32,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
jsonText: string;
configFileName: string;
basePath: string;
allFileList: string[];
allFileList: string[] | vfs.FileSet;
}
function baselinedParsed(subScenario: string, scenario: () => VerifyConfig[], skipJson?: true) {
@@ -42,7 +42,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
input: () =>
scenario().map(({ jsonText, configFileName, basePath, allFileList }) => ({
createHost: () => {
const files = allFileList.reduce((files, value) => (files[value] = "", files), {} as vfs.FileSet);
const files = ts.isArray(allFileList) ? allFileList.reduce((files, value) => (files[value] = "", files), {} as vfs.FileSet) : allFileList;
files[ts.combinePaths(basePath, configFileName)] = jsonText;
return new fakes.ParseConfigHost(
new vfs.FileSystem(
@@ -211,6 +211,38 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
];
});
baselinedParsed("with outDir from base tsconfig", () => {
const tsconfigWithoutConfigDir = jsonToReadableText({
extends: "./tsconfigWithoutConfigDir.json",
});
const tsconfigWithConfigDir = jsonToReadableText({
extends: "./tsconfigWithConfigDir.json",
});
const basePath = "/";
return [
{
jsonText: tsconfigWithoutConfigDir,
configFileName: "tsconfig.json",
basePath,
allFileList: {
"/tsconfigWithoutConfigDir.json": jsonToReadableText({ compilerOptions: { outDir: "bin" } }),
"/bin/a.ts": "",
"/b.ts": "",
},
},
{
jsonText: tsconfigWithConfigDir,
configFileName: "tsconfig.json",
basePath,
allFileList: {
"/tsconfigWithConfigDir.json": jsonToReadableText({ compilerOptions: { outDir: "${configDir}/bin" } }), // eslint-disable-line no-template-curly-in-string
"/bin/a.ts": "",
"/b.ts": "",
},
},
];
});
baselinedParsed("implicitly exclude common package folders", () => [{
jsonText: `{}`,
configFileName: "tsconfig.json",
@@ -241,7 +273,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
"files": []
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -251,7 +283,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
"references": []
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -261,7 +293,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
"references": [{ "path": "/apath" }]
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -269,7 +301,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
jsonText: `{
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.js"],
}]);
@@ -280,7 +312,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
}
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: [],
}]);
@@ -301,7 +333,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
"include": ["**/*"]
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -314,7 +346,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
}
}`,
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}], /*skipJson*/ true);
@@ -328,7 +360,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
}],
}),
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -339,7 +371,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
],
}),
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -350,7 +382,7 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
},
}),
configFileName: "/apath/tsconfig.json",
basePath: "tests/cases/unittests",
basePath: "/apath",
allFileList: ["/apath/a.ts"],
}]);
@@ -392,6 +424,6 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
jsonText: jsonToReadableText({
include: ["./", "./**/*.json"],
}),
basePath: "/foo",
basePath: "/foo.bar",
}]);
});

View File

@@ -32,6 +32,6 @@
"./src/**/*"
],
"exclude": [
"./lib"
"/Show TSConfig with paths and more/lib"
]
}

View File

@@ -13,7 +13,7 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
/apath/tsconfig.json:2:26 - error TS18002: The 'files' list in config file '/apath/tsconfig.json' is empty.
tsconfig.json:2:26 - error TS18002: The 'files' list in config file '/apath/tsconfig.json' is empty.
2 "files": [],
   ~~

View File

@@ -12,7 +12,7 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
/apath/tsconfig.json:2:26 - error TS18002: The 'files' list in config file '/apath/tsconfig.json' is empty.
tsconfig.json:2:26 - error TS18002: The 'files' list in config file '/apath/tsconfig.json' is empty.
2 "files": []
   ~~

View File

@@ -15,5 +15,5 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
error TS18003: No inputs were found in config file '/apath/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./"]'.
error TS18003: No inputs were found in config file '/apath/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/apath"]'.

View File

@@ -15,5 +15,5 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
error TS18003: No inputs were found in config file '/apath/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./"]'.
error TS18003: No inputs were found in config file '/apath/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/apath"]'.

View File

@@ -16,39 +16,39 @@ configFileName:: /apath/tsconfig.json
FileNames::
/apath/a.ts
Errors::
/apath/tsconfig.json:3:17 - error TS1327: String literal with double quotes expected.
tsconfig.json:3:17 - error TS1327: String literal with double quotes expected.
3 ## this comment does cause issues
   ~
/apath/tsconfig.json:3:18 - error TS1328: Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.
tsconfig.json:3:18 - error TS1328: Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.
3 ## this comment does cause issues
   ~
/apath/tsconfig.json:3:17 - error TS5023: Unknown compiler option '#'.
tsconfig.json:3:17 - error TS5023: Unknown compiler option '#'.
3 ## this comment does cause issues
   ~
/apath/tsconfig.json:3:20 - error TS1327: String literal with double quotes expected.
tsconfig.json:3:20 - error TS1327: String literal with double quotes expected.
3 ## this comment does cause issues
   ~~~~
/apath/tsconfig.json:3:25 - error TS1328: Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.
tsconfig.json:3:25 - error TS1328: Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.
3 ## this comment does cause issues
   ~~~~~~~
/apath/tsconfig.json:3:20 - error TS5023: Unknown compiler option 'this'.
tsconfig.json:3:20 - error TS5023: Unknown compiler option 'this'.
3 ## this comment does cause issues
   ~~~~
/apath/tsconfig.json:3:33 - error TS1136: Property assignment expected.
tsconfig.json:3:33 - error TS1136: Property assignment expected.
3 ## this comment does cause issues
   ~~~~
/apath/tsconfig.json:3:38 - error TS1136: Property assignment expected.
tsconfig.json:3:38 - error TS1136: Property assignment expected.
3 ## this comment does cause issues
   ~~~~~
/apath/tsconfig.json:3:44 - error TS1136: Property assignment expected.
tsconfig.json:3:44 - error TS1136: Property assignment expected.
3 ## this comment does cause issues
   ~~~~~~

View File

@@ -14,7 +14,7 @@ configFileName:: /apath/tsconfig.json
FileNames::
/apath/a.ts
Errors::
/apath/tsconfig.json:3:5 - error TS6266: Option 'help' can only be specified on command line.
tsconfig.json:3:5 - error TS6266: Option 'help' can only be specified on command line.
3 "help": true
   ~~~~~~

View File

@@ -19,7 +19,7 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
/apath/tsconfig.json:3:5 - error TS5024: Compiler option 'files' requires a value of type string.
tsconfig.json:3:5 - error TS5024: Compiler option 'files' requires a value of type string.
 3 {
   ~

View File

@@ -16,7 +16,7 @@ configFileName:: /apath/tsconfig.json
FileNames::
Errors::
/apath/tsconfig.json:3:5 - error TS5024: Compiler option 'include' requires a value of type string.
tsconfig.json:3:5 - error TS5024: Compiler option 'include' requires a value of type string.
3 [
   ~

View File

@@ -0,0 +1,51 @@
Fs::
//// [/b.ts]
//// [/bin/a.ts]
//// [/tsconfig.json]
{
"extends": "./tsconfigWithoutConfigDir.json"
}
//// [/tsconfigWithoutConfigDir.json]
{
"compilerOptions": {
"outDir": "bin"
}
}
configFileName:: tsconfig.json
FileNames::
/b.ts
Errors::
Fs::
//// [/b.ts]
//// [/bin/a.ts]
//// [/tsconfig.json]
{
"extends": "./tsconfigWithConfigDir.json"
}
//// [/tsconfigWithConfigDir.json]
{
"compilerOptions": {
"outDir": "${configDir}/bin"
}
}
configFileName:: tsconfig.json
FileNames::
/b.ts
Errors::

View File

@@ -0,0 +1,51 @@
Fs::
//// [/b.ts]
//// [/bin/a.ts]
//// [/tsconfig.json]
{
"extends": "./tsconfigWithoutConfigDir.json"
}
//// [/tsconfigWithoutConfigDir.json]
{
"compilerOptions": {
"outDir": "bin"
}
}
configFileName:: tsconfig.json
FileNames::
/b.ts
Errors::
Fs::
//// [/b.ts]
//// [/bin/a.ts]
//// [/tsconfig.json]
{
"extends": "./tsconfigWithConfigDir.json"
}
//// [/tsconfigWithConfigDir.json]
{
"compilerOptions": {
"outDir": "${configDir}/bin"
}
}
configFileName:: tsconfig.json
FileNames::
/b.ts
Errors::

View File

@@ -136,7 +136,8 @@ Output::
"/home/src/projects/myproject/src"
],
"exclude": [
"outDir"
"/home/src/projects/myproject/outDir",
"/home/src/projects/myproject/decls"
]
}
exitCode:: ExitStatus.Success