mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-13 22:00:59 -05:00
Fix the implicit glob key so that recursive keys are not differing just directory separator for wildcard directory (#49246)
* Add failing test * Fix the implicit glob key so that recursive keys are not differing just by directory seperator Fixes #49078 * Reset the reload level once program is loaded
This commit is contained in:
@@ -3548,7 +3548,7 @@ namespace ts {
|
||||
}
|
||||
if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
|
||||
return {
|
||||
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
|
||||
key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec)),
|
||||
flags: WatchDirectoryFlags.Recursive
|
||||
};
|
||||
}
|
||||
|
||||
@@ -700,6 +700,7 @@ namespace ts {
|
||||
|
||||
function reloadFileNamesFromConfigFile() {
|
||||
writeLog("Reloading new file names and options");
|
||||
reloadLevel = ConfigFileProgramReloadLevel.None;
|
||||
rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile!.configFileSpecs!, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
|
||||
if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile!.configFileSpecs!, configFileParsingDiagnostics!, canConfigFileJsonReportNoInputFiles)) {
|
||||
hasChangedConfigFileParsingErrors = true;
|
||||
|
||||
@@ -421,5 +421,14 @@ namespace ts {
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo.bar");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo.bar/src": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
|
||||
it("correctly parses wild card directories from implicit glob when two keys differ only in directory seperator", () => {
|
||||
const parsed = parseConfigFileTextToJson("/foo.bar/tsconfig.json", JSON.stringify({
|
||||
include: ["./", "./**/*.json"]
|
||||
}));
|
||||
|
||||
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo");
|
||||
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo": WatchDirectoryFlags.Recursive });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -616,6 +616,39 @@ export class A {
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "correctly parses wild card directories from implicit glob when two keys differ only in directory seperator",
|
||||
commandLineArgs: ["-w", "--extendedDiagnostics"],
|
||||
sys: () => {
|
||||
const file1 = {
|
||||
path: `${projectRoot}/f1.ts`,
|
||||
content: "export const x = 1"
|
||||
};
|
||||
const file2 = {
|
||||
path: `${projectRoot}/f2.ts`,
|
||||
content: "export const y = 1"
|
||||
};
|
||||
const configFile = {
|
||||
path: `${projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ compilerOptions: { composite: true }, include: ["./", "./**/*.json"] })
|
||||
};
|
||||
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: projectRoot });
|
||||
},
|
||||
changes: [
|
||||
{
|
||||
caption: "Add new file",
|
||||
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
},
|
||||
{
|
||||
caption: "Import new file",
|
||||
change: sys => sys.prependFile(`${projectRoot}/f1.ts`, `import { z } from "./new-file";`),
|
||||
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
verifyTscWatch({
|
||||
scenario,
|
||||
subScenario: "can correctly update configured project when set of root files has changed through include",
|
||||
|
||||
Reference in New Issue
Block a user