@@ -43,6 +43,8 @@ export class TSServiceManager {
43
43
export class TSService {
44
44
private readonly watch : ts . WatchOfConfigFile < ts . BuilderProgram > ;
45
45
46
+ private readonly tsconfigPath : string ;
47
+
46
48
public readonly extraFileExtensions : string [ ] ;
47
49
48
50
private currTarget = {
@@ -53,9 +55,8 @@ export class TSService {
53
55
54
56
private readonly fileWatchCallbacks = new Map < string , ( ) => void > ( ) ;
55
57
56
- private readonly dirWatchCallbacks = new Map < string , ( ) => void > ( ) ;
57
-
58
58
public constructor ( tsconfigPath : string , extraFileExtensions : string [ ] ) {
59
+ this . tsconfigPath = tsconfigPath ;
59
60
this . extraFileExtensions = extraFileExtensions ;
60
61
this . watch = this . createWatch ( tsconfigPath , extraFileExtensions ) ;
61
62
}
@@ -77,31 +78,13 @@ export class TSService {
77
78
filePath : normalized ,
78
79
dirMap,
79
80
} ;
80
- for ( const { filePath : targetPath , dirMap : map } of [
81
- this . currTarget ,
82
- lastTarget ,
83
- ] ) {
81
+ for ( const { filePath : targetPath } of [ this . currTarget , lastTarget ] ) {
84
82
if ( ! targetPath ) continue ;
85
- if ( ts . sys . fileExists ( targetPath ) ) {
86
- getFileNamesIncludingVirtualTSX (
87
- targetPath ,
88
- this . extraFileExtensions
89
- ) . forEach ( ( vFilePath ) => {
90
- this . fileWatchCallbacks . get ( vFilePath ) ?.( ) ;
91
- } ) ;
92
- } else {
83
+ if ( ! ts . sys . fileExists ( targetPath ) ) {
93
84
// Signal a directory change to request a re-scan of the directory
94
85
// because it targets a file that does not actually exist.
95
- for ( const dirName of map . keys ( ) ) {
96
- this . dirWatchCallbacks . get ( dirName ) ?.( ) ;
97
- }
86
+ this . fileWatchCallbacks . get ( normalizeFileName ( this . tsconfigPath ) ) ?.( ) ;
98
87
}
99
- }
100
-
101
- const refreshTargetPaths = [ normalized , lastTarget . filePath ] . filter (
102
- ( s ) => s
103
- ) ;
104
- for ( const targetPath of refreshTargetPaths ) {
105
88
getFileNamesIncludingVirtualTSX (
106
89
targetPath ,
107
90
this . extraFileExtensions
@@ -281,12 +264,10 @@ export class TSService {
281
264
} ;
282
265
} ;
283
266
// Use watchCompilerHost but don't actually watch the files and directories.
284
- watchCompilerHost . watchDirectory = ( dirName , callback ) => {
285
- const normalized = normalizeFileName ( dirName ) ;
286
- this . dirWatchCallbacks . set ( normalized , ( ) => callback ( dirName ) ) ;
267
+ watchCompilerHost . watchDirectory = ( ) => {
287
268
return {
288
269
close : ( ) => {
289
- this . dirWatchCallbacks . delete ( normalized ) ;
270
+ // noop
290
271
} ,
291
272
} ;
292
273
} ;
0 commit comments