Skip to content

Commit f628bf8

Browse files
authored
Fix casing for wild card keys for implicit globs to get wild card directories to watch (#39049)
* Test showing how wild card directory is not watched because of mismatch in key case * Fix casing for wild card keys for implicit globs Fixes #36532
1 parent b4735c0 commit f628bf8

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,10 @@ namespace ts {
31203120
};
31213121
}
31223122
if (isImplicitGlob(spec)) {
3123-
return { key: spec, flags: WatchDirectoryFlags.Recursive };
3123+
return {
3124+
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
3125+
flags: WatchDirectoryFlags.Recursive
3126+
};
31243127
}
31253128
return undefined;
31263129
}

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,30 @@ export class A {
556556
]
557557
});
558558

559+
verifyTscWatch({
560+
scenario,
561+
subScenario: "can correctly update configured project when set of root files has changed through include",
562+
commandLineArgs: ["-w", "-p", "."],
563+
sys: () => {
564+
const file1 = {
565+
path: `${projectRoot}/Project/file1.ts`,
566+
content: "export const x = 10;"
567+
};
568+
const configFile = {
569+
path: `${projectRoot}/Project/tsconfig.json`,
570+
content: JSON.stringify({ include: [".", "./**/*.json"] })
571+
};
572+
return createWatchedSystem([file1, libFile, configFile], { currentDirectory: `${projectRoot}/Project` });
573+
},
574+
changes: [
575+
{
576+
caption: "Write file2",
577+
change: sys => sys.writeFile(`${projectRoot}/Project/file2.ts`, "export const y = 10;"),
578+
timeouts: checkSingleTimeoutQueueLengthAndRun
579+
}
580+
]
581+
});
582+
559583
verifyTscWatch({
560584
scenario,
561585
subScenario: "can update configured project when set of root files was not changed",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Input::
2+
//// [/user/username/projects/myproject/Project/file1.ts]
3+
export const x = 10;
4+
5+
//// [/a/lib/lib.d.ts]
6+
/// <reference no-default-lib="true"/>
7+
interface Boolean {}
8+
interface Function {}
9+
interface CallableFunction {}
10+
interface NewableFunction {}
11+
interface IArguments {}
12+
interface Number { toExponential: any; }
13+
interface Object {}
14+
interface RegExp {}
15+
interface String { charAt: any; }
16+
interface Array<T> { length: number; [n: number]: T; }
17+
18+
//// [/user/username/projects/myproject/Project/tsconfig.json]
19+
{"include":[".","./**/*.json"]}
20+
21+
22+
/a/lib/tsc.js -w -p .
23+
Output::
24+
>> Screen clear
25+
[12:00:23 AM] Starting compilation in watch mode...
26+
27+
28+
[12:00:26 AM] Found 0 errors. Watching for file changes.
29+
30+
31+
32+
Program root files: ["/user/username/projects/myproject/Project/file1.ts"]
33+
Program options: {"watch":true,"project":"/user/username/projects/myproject/Project","configFilePath":"/user/username/projects/myproject/Project/tsconfig.json"}
34+
Program files::
35+
/a/lib/lib.d.ts
36+
/user/username/projects/myproject/Project/file1.ts
37+
38+
Semantic diagnostics in builder refreshed for::
39+
/a/lib/lib.d.ts
40+
/user/username/projects/myproject/Project/file1.ts
41+
42+
WatchedFiles::
43+
/user/username/projects/myproject/project/tsconfig.json:
44+
{"fileName":"/user/username/projects/myproject/Project/tsconfig.json","pollingInterval":250}
45+
/user/username/projects/myproject/project/file1.ts:
46+
{"fileName":"/user/username/projects/myproject/Project/file1.ts","pollingInterval":250}
47+
/a/lib/lib.d.ts:
48+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
49+
50+
FsWatches::
51+
52+
FsWatchesRecursive::
53+
/user/username/projects/myproject/project/node_modules/@types:
54+
{"directoryName":"/user/username/projects/myproject/Project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
55+
/user/username/projects/myproject/node_modules/@types:
56+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
57+
/user/username/projects/myproject/project:
58+
{"directoryName":"/user/username/projects/myproject/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
59+
60+
exitCode:: ExitStatus.undefined
61+
62+
//// [/user/username/projects/myproject/Project/file1.js]
63+
"use strict";
64+
exports.__esModule = true;
65+
exports.x = void 0;
66+
exports.x = 10;
67+
68+
69+
70+
Change:: Write file2
71+
72+
Input::
73+
//// [/user/username/projects/myproject/Project/file2.ts]
74+
export const y = 10;
75+
76+
77+
Output::
78+
>> Screen clear
79+
[12:00:29 AM] File change detected. Starting incremental compilation...
80+
81+
82+
[12:00:32 AM] Found 0 errors. Watching for file changes.
83+
84+
85+
86+
Program root files: ["/user/username/projects/myproject/Project/file1.ts","/user/username/projects/myproject/Project/file2.ts"]
87+
Program options: {"watch":true,"project":"/user/username/projects/myproject/Project","configFilePath":"/user/username/projects/myproject/Project/tsconfig.json"}
88+
Program files::
89+
/a/lib/lib.d.ts
90+
/user/username/projects/myproject/Project/file1.ts
91+
/user/username/projects/myproject/Project/file2.ts
92+
93+
Semantic diagnostics in builder refreshed for::
94+
/user/username/projects/myproject/Project/file2.ts
95+
96+
WatchedFiles::
97+
/user/username/projects/myproject/project/tsconfig.json:
98+
{"fileName":"/user/username/projects/myproject/Project/tsconfig.json","pollingInterval":250}
99+
/user/username/projects/myproject/project/file1.ts:
100+
{"fileName":"/user/username/projects/myproject/Project/file1.ts","pollingInterval":250}
101+
/a/lib/lib.d.ts:
102+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
103+
/user/username/projects/myproject/project/file2.ts:
104+
{"fileName":"/user/username/projects/myproject/Project/file2.ts","pollingInterval":250}
105+
106+
FsWatches::
107+
108+
FsWatchesRecursive::
109+
/user/username/projects/myproject/project/node_modules/@types:
110+
{"directoryName":"/user/username/projects/myproject/Project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
111+
/user/username/projects/myproject/node_modules/@types:
112+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
113+
/user/username/projects/myproject/project:
114+
{"directoryName":"/user/username/projects/myproject/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
115+
116+
exitCode:: ExitStatus.undefined
117+
118+
//// [/user/username/projects/myproject/Project/file2.js]
119+
"use strict";
120+
exports.__esModule = true;
121+
exports.y = void 0;
122+
exports.y = 10;
123+
124+

0 commit comments

Comments
 (0)