Skip to content

Commit 66d51e5

Browse files
committed
Fix the implicit glob key so that recursive keys are not differing just by directory seperator
Fixes microsoft#49078
1 parent b846905 commit 66d51e5

File tree

3 files changed

+110
-25
lines changed

3 files changed

+110
-25
lines changed

src/compiler/commandLineParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3548,7 +3548,7 @@ namespace ts {
35483548
}
35493549
if (isImplicitGlob(spec.substring(spec.lastIndexOf(directorySeparator) + 1))) {
35503550
return {
3551-
key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec),
3551+
key: removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec)),
35523552
flags: WatchDirectoryFlags.Recursive
35533553
};
35543554
}

src/testRunner/unittests/tscWatch/programUpdates.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ export class A {
639639
{
640640
caption: "Add new file",
641641
change: sys => sys.writeFile(`${projectRoot}/new-file.ts`, "export const z = 1;"),
642-
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(0),
642+
timeouts: sys => sys.checkTimeoutQueueLengthAndRun(1),
643643
},
644644
{
645645
caption: "Import new file",

tests/baselines/reference/tscWatch/programUpdates/correctly-parses-wild-card-directories-from-implicit-glob-when-two-keys-differ-only-in-directory-seperator.js

+108-23
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_mod
3939
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
4040
[12:00:34 AM] Found 0 errors. Watching for file changes.
4141

42+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
43+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
4244

4345

4446
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
@@ -74,6 +76,8 @@ FsWatches::
7476
FsWatchesRecursive::
7577
/user/username/projects/myproject/node_modules/@types:
7678
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
79+
/user/username/projects/myproject:
80+
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
7781

7882
exitCode:: ExitStatus.undefined
7983

@@ -149,6 +153,41 @@ export const z = 1;
149153

150154

151155
Output::
156+
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
157+
Scheduling update
158+
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
159+
Reloading new file names and options
160+
Synchronizing program
161+
[12:00:39 AM] File change detected. Starting incremental compilation...
162+
163+
CreatingProgramWith::
164+
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
165+
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
166+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/new-file.ts 250 undefined Source file
167+
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.js :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
168+
Project: /user/username/projects/myproject/tsconfig.json Detected file add/remove of non supported extension: /user/username/projects/myproject/new-file.js
169+
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.js :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
170+
DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.d.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
171+
Project: /user/username/projects/myproject/tsconfig.json Detected output file: /user/username/projects/myproject/new-file.d.ts
172+
Elapsed:: *ms DirectoryWatcher:: Triggered with /user/username/projects/myproject/new-file.d.ts :: WatchInfo: /user/username/projects/myproject 1 undefined Wild card directory
173+
[12:00:47 AM] Found 0 errors. Watching for file changes.
174+
175+
176+
177+
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
178+
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
179+
Program structureReused: Not
180+
Program files::
181+
/a/lib/lib.d.ts
182+
/user/username/projects/myproject/f1.ts
183+
/user/username/projects/myproject/f2.ts
184+
/user/username/projects/myproject/new-file.ts
185+
186+
Semantic diagnostics in builder refreshed for::
187+
/user/username/projects/myproject/new-file.ts
188+
189+
Shape signatures in builder refreshed for::
190+
/user/username/projects/myproject/new-file.ts (computed .d.ts)
152191

153192
WatchedFiles::
154193
/user/username/projects/myproject/tsconfig.json:
@@ -159,15 +198,77 @@ WatchedFiles::
159198
{"fileName":"/user/username/projects/myproject/f2.ts","pollingInterval":250}
160199
/a/lib/lib.d.ts:
161200
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
201+
/user/username/projects/myproject/new-file.ts:
202+
{"fileName":"/user/username/projects/myproject/new-file.ts","pollingInterval":250}
162203

163204
FsWatches::
164205

165206
FsWatchesRecursive::
166207
/user/username/projects/myproject/node_modules/@types:
167208
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
209+
/user/username/projects/myproject:
210+
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
168211

169212
exitCode:: ExitStatus.undefined
170213

214+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo]
215+
{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./f1.ts","./f2.ts","./new-file.ts"],"fileInfos":[{"version":"-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }","affectsGlobalScope":true},{"version":"-10906998252-export const x = 1","signature":"-7495133367-export declare const x = 1;\n"},{"version":"-10905812331-export const y = 1","signature":"-6203665398-export declare const y = 1;\n"},{"version":"-11960320495-export const z = 1;","signature":"-9207164725-export declare const z = 1;\n"}],"options":{"composite":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2,3,4]},"version":"FakeTSVersion"}
216+
217+
//// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt]
218+
{
219+
"program": {
220+
"fileNames": [
221+
"../../../../a/lib/lib.d.ts",
222+
"./f1.ts",
223+
"./f2.ts",
224+
"./new-file.ts"
225+
],
226+
"fileInfos": {
227+
"../../../../a/lib/lib.d.ts": {
228+
"version": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
229+
"signature": "-7698705165-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }",
230+
"affectsGlobalScope": true
231+
},
232+
"./f1.ts": {
233+
"version": "-10906998252-export const x = 1",
234+
"signature": "-7495133367-export declare const x = 1;\n"
235+
},
236+
"./f2.ts": {
237+
"version": "-10905812331-export const y = 1",
238+
"signature": "-6203665398-export declare const y = 1;\n"
239+
},
240+
"./new-file.ts": {
241+
"version": "-11960320495-export const z = 1;",
242+
"signature": "-9207164725-export declare const z = 1;\n"
243+
}
244+
},
245+
"options": {
246+
"composite": true
247+
},
248+
"referencedMap": {},
249+
"exportedModulesMap": {},
250+
"semanticDiagnosticsPerFile": [
251+
"../../../../a/lib/lib.d.ts",
252+
"./f1.ts",
253+
"./f2.ts",
254+
"./new-file.ts"
255+
]
256+
},
257+
"version": "FakeTSVersion",
258+
"size": 949
259+
}
260+
261+
//// [/user/username/projects/myproject/new-file.js]
262+
"use strict";
263+
exports.__esModule = true;
264+
exports.z = void 0;
265+
exports.z = 1;
266+
267+
268+
//// [/user/username/projects/myproject/new-file.d.ts]
269+
export declare const z = 1;
270+
271+
171272

172273
Change:: Import new file
173274

@@ -180,23 +281,18 @@ Output::
180281
FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
181282
Scheduling update
182283
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/f1.ts 1:: WatchInfo: /user/username/projects/myproject/f1.ts 250 undefined Source file
284+
Reloading new file names and options
183285
Synchronizing program
184-
[[90m12:00:41 AM[0m] File change detected. Starting incremental compilation...
286+
[[90m12:00:53 AM[0m] File change detected. Starting incremental compilation...
185287

186288
CreatingProgramWith::
187-
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
289+
roots: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
188290
options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
189-
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/new-file.ts 250 undefined Source file
190-
f1.ts:1:19 - error TS6307: File '/user/username/projects/myproject/new-file.ts' is not listed within the file list of project '/user/username/projects/myproject/tsconfig.json'. Projects must list all files or use an 'include' pattern.
191-
192-
1 import { z } from "./new-file";export const x = 1
193-
   ~~~~~~~~~~~~
194-
195-
[12:00:55 AM] Found 1 error. Watching for file changes.
291+
[12:01:03 AM] Found 0 errors. Watching for file changes.
196292

197293

198294

199-
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts"]
295+
Program root files: ["/user/username/projects/myproject/f1.ts","/user/username/projects/myproject/f2.ts","/user/username/projects/myproject/new-file.ts"]
200296
Program options: {"composite":true,"watch":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
201297
Program structureReused: SafeModules
202298
Program files::
@@ -206,11 +302,9 @@ Program files::
206302
/user/username/projects/myproject/f2.ts
207303

208304
Semantic diagnostics in builder refreshed for::
209-
/user/username/projects/myproject/new-file.ts
210305
/user/username/projects/myproject/f1.ts
211306

212307
Shape signatures in builder refreshed for::
213-
/user/username/projects/myproject/new-file.ts (computed .d.ts)
214308
/user/username/projects/myproject/f1.ts (computed .d.ts)
215309

216310
WatchedFiles::
@@ -230,6 +324,8 @@ FsWatches::
230324
FsWatchesRecursive::
231325
/user/username/projects/myproject/node_modules/@types:
232326
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
327+
/user/username/projects/myproject:
328+
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
233329

234330
exitCode:: ExitStatus.undefined
235331

@@ -291,14 +387,3 @@ exitCode:: ExitStatus.undefined
291387
"size": 1005
292388
}
293389

294-
//// [/user/username/projects/myproject/new-file.js]
295-
"use strict";
296-
exports.__esModule = true;
297-
exports.z = void 0;
298-
exports.z = 1;
299-
300-
301-
//// [/user/username/projects/myproject/new-file.d.ts]
302-
export declare const z = 1;
303-
304-

0 commit comments

Comments
 (0)