Fix file matching with tsx and dts of same name are included by include patterns (#55690)

This commit is contained in:
Sheetal Nandi
2023-09-12 13:10:34 -07:00
committed by GitHub
parent 3bc41784f0
commit 3ade5022d7
18 changed files with 1254 additions and 2 deletions

View File

@@ -141,6 +141,26 @@ const caseSensitiveOrderingDiffersWithCaseHost = new fakes.ParseConfigHost(
}),
);
const caseInsensitiveHostWithSameFileNamesWithDifferentExtensions = new fakes.ParseConfigHost(
new vfs.FileSystem(/*ignoreCase*/ true, {
cwd: caseInsensitiveBasePath,
files: {
"c:/dev/a.tsx": "",
"c:/dev/a.d.ts": "",
"c:/dev/b.tsx": "",
"c:/dev/b.ts": "",
"c:/dev/c.tsx": "",
"c:/dev/m.ts": "",
"c:/dev/m.d.ts": "",
"c:/dev/n.tsx": "",
"c:/dev/n.ts": "",
"c:/dev/n.d.ts": "",
"c:/dev/o.ts": "",
"c:/dev/x.d.ts": "",
},
}),
);
function baselineMatches(subScenario: string, json: any, host: fakes.ParseConfigHost, basePath: string) {
const jsonText = JSON.stringify(json, undefined, " ");
baselineParseConfig({
@@ -839,6 +859,51 @@ describe("unittests:: config:: matchFiles", () => {
caseInsensitiveBasePath,
);
});
describe("sameNamedDeclarations", () => {
baselineMatches(
"same named declarations with include ts",
{ include: ["*.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include ts dts",
{ include: ["*.ts", "*.d.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include tsx",
{ include: ["*.tsx"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include tsx ts",
{ include: ["*.tsx", "*.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include ts tsx",
{ include: ["*.tsx", "*.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include tsx dts",
{ include: ["*.tsx", "*.d.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
baselineMatches(
"same named declarations with include dts tsx",
{ include: ["*.tsx", "*.d.ts"] },
caseInsensitiveHostWithSameFileNamesWithDifferentExtensions,
caseInsensitiveBasePath,
);
});
});
describe("with files or folders that begin with a .", () => {

View File

@@ -1,11 +1,15 @@
import {
noop,
} from "../../_namespaces/ts";
import {
noChangeRun,
verifyTsc,
} from "../helpers/tsc";
import {
loadProjectFromFiles,
} from "../helpers/vfs";
describe("unittests:: tsbuild - clean", () => {
describe("unittests:: tsbuild - clean::", () => {
verifyTsc({
scenario: "clean",
subScenario: `file name and output name clashing`,
@@ -19,4 +23,26 @@ describe("unittests:: tsbuild - clean", () => {
}),
}),
});
verifyTsc({
scenario: "clean",
subScenario: "tsx with dts emit",
fs: () =>
loadProjectFromFiles({
"/src/project/src/main.tsx": "export const x = 10;",
"/src/project/tsconfig.json": JSON.stringify({
compilerOptions: { declaration: true },
include: ["src/**/*.tsx", "src/**/*.ts"],
}),
}),
commandLineArgs: ["--b", "src/project", "-v", "--explainFiles"],
edits: [
noChangeRun,
{
caption: "clean build",
edit: noop,
commandLineArgs: ["-b", "/src/project", "--clean"],
},
],
});
});