Keep extended config's raw file, include, exclude relative to itself and correct it when setting extending options (#42544)

* Test when config file extends is incorrectly computed
Test for #40720

* Keep extended config's raw file, include, exclude relative to itself and correct it when setting extending options
Fixes #40720
This commit is contained in:
Sheetal Nandi
2021-02-03 11:09:06 -08:00
committed by GitHub
parent 1c25b009f2
commit c3e132da59
5 changed files with 382 additions and 23 deletions

View File

@@ -112,6 +112,7 @@
"unittests/services/transpile.ts",
"unittests/tsbuild/amdModulesWithOut.ts",
"unittests/tsbuild/configFileErrors.ts",
"unittests/tsbuild/configFileExtends.ts",
"unittests/tsbuild/containerOnlyReferenced.ts",
"unittests/tsbuild/declarationEmit.ts",
"unittests/tsbuild/demo.ts",

View File

@@ -0,0 +1,52 @@
namespace ts {
describe("unittests:: tsbuild:: configFileExtends:: when tsconfig extends another config", () => {
function getConfigExtendsWithIncludeFs() {
return loadProjectFromFiles({
"/src/tsconfig.json": JSON.stringify({
references: [
{ path: "./shared/tsconfig.json" },
{ path: "./webpack/tsconfig.json" }
],
files: []
}),
"/src/shared/tsconfig-base.json": JSON.stringify({
include: ["./typings-base/"]
}),
"/src/shared/typings-base/globals.d.ts": `type Unrestricted = any;`,
"/src/shared/tsconfig.json": JSON.stringify({
extends: "./tsconfig-base.json",
compilerOptions: {
composite: true,
outDir: "../target-tsc-build/",
rootDir: ".."
},
files: ["./index.ts"]
}),
"/src/shared/index.ts": `export const a: Unrestricted = 1;`,
"/src/webpack/tsconfig.json": JSON.stringify({
extends: "../shared/tsconfig-base.json",
compilerOptions: {
composite: true,
outDir: "../target-tsc-build/",
rootDir: ".."
},
files: ["./index.ts"],
references: [{ path: "../shared/tsconfig.json" }]
}),
"/src/webpack/index.ts": `export const b: Unrestricted = 1;`,
});
}
verifyTsc({
scenario: "configFileExtends",
subScenario: "when building solution with projects extends config with include",
fs: getConfigExtendsWithIncludeFs,
commandLineArgs: ["--b", "/src/tsconfig.json", "--v", "--listFiles"],
});
verifyTsc({
scenario: "configFileExtends",
subScenario: "when building project uses reference and both extend config with include",
fs: getConfigExtendsWithIncludeFs,
commandLineArgs: ["--b", "/src/webpack/tsconfig.json", "--v", "--listFiles"],
});
});
}