Skip to content

Commit 61eac59

Browse files
sheetalkamattypescript-bot
authored andcommitted
Cherry-pick PR microsoft#49246 into release-4.7
Component commits: b846905 Add failing test 66d51e5 Fix the implicit glob key so that recursive keys are not differing just by directory seperator Fixes microsoft#49078 f93951f Reset the reload level once program is loaded
1 parent cfd1a6e commit 61eac59

File tree

5 files changed

+432
-1
lines changed

5 files changed

+432
-1
lines changed

src/compiler/commandLineParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,7 @@ namespace ts {
35423542
}
35433543
if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
35443544
return {
3545-
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
3545+
key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec)),
35463546
flags: WatchDirectoryFlags.Recursive
35473547
};
35483548
}

src/compiler/watchPublic.ts

+1
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ namespace ts {
700700

701701
function reloadFileNamesFromConfigFile() {
702702
writeLog("Reloading new file names and options");
703+
reloadLevel = ConfigFileProgramReloadLevel.None;
703704
rootFileNames = getFileNamesFromConfigSpecs(compilerOptions.configFile!.configFileSpecs!, getNormalizedAbsolutePath(getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
704705
if (updateErrorForNoInputFiles(rootFileNames, getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile!.configFileSpecs!, configFileParsingDiagnostics!, canConfigFileJsonReportNoInputFiles)) {
705706
hasChangedConfigFileParsingErrors = true;

src/testRunner/unittests/config/tsconfigParsing.ts

+9
Original file line numberDiff line numberDiff line change
@@ -421,5 +421,14 @@ namespace ts {
421421
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo.bar");
422422
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo.bar/src": WatchDirectoryFlags.Recursive });
423423
});
424+
425+
it("correctly parses wild card directories from implicit glob when two keys differ only in directory seperator", () => {
426+
const parsed = parseConfigFileTextToJson("/foo.bar/tsconfig.json", JSON.stringify({
427+
include: ["./", "./**/*.json"]
428+
}));
429+
430+
const parsedCommand = parseJsonConfigFileContent(parsed.config, sys, "/foo");
431+
assert.deepEqual(parsedCommand.wildcardDirectories, { "/foo": WatchDirectoryFlags.Recursive });
432+
});
424433
});
425434
}

src/testRunner/unittests/tscWatch/programUpdates.ts

+33
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,39 @@ export class A {
616616
]
617617
});
618618

619+
verifyTscWatch({
620+
scenario,
621+
subScenario: "correctly parses wild card directories from implicit glob when two keys differ only in directory seperator",
622+
commandLineArgs: ["-w", "--extendedDiagnostics"],
623+
sys: () => {
624+
const file1 = {
625+
path: `${projectRoot}/f1.ts`,
626+
content: "export const x = 1"
627+
};
628+
const file2 = {
629+
path: `${projectRoot}/f2.ts`,
630+
content: "export const y = 1"
631+
};
632+
const configFile = {
633+
path: `${projectRoot}/tsconfig.json`,
634+
content: JSON.stringify({ compilerOptions: { composite: true }, include: ["./", "./**/*.json"] })
635+
};
636+
return createWatchedSystem([file1, file2, libFile, configFile], { currentDirectory: projectRoot });
637+
},
638+
changes: [
639+
{
640+
caption: "Add new file",
641+
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
642+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
643+
},
644+
{
645+
caption: "Import new file",
646+
change: sys => sys.prependFile(`${projectRoot}/f1.ts`, `import { z } from "./new-file";`),
647+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
648+
}
649+
]
650+
});
651+
619652
verifyTscWatch({
620653
scenario,
621654
subScenario: "can correctly update configured project when set of root files has changed through include",

0 commit comments

Comments
 (0)