@@ -1939,7 +1939,7 @@ namespace ts.projectSystem {
1939
1939
content : JSON . stringify ( { compilerOptions : { allowJs : true } , exclude : [ "node_modules" ] } )
1940
1940
} ;
1941
1941
const host = createServerHost ( [ f1 , barjs , barTypings , config ] ) ;
1942
- const projectService = createProjectService ( host , { typingsInstaller : new TestTypingsInstaller ( typingsCacheLocation , host ) } ) ;
1942
+ const projectService = createProjectService ( host , { typingsInstaller : new TestTypingsInstaller ( typingsCacheLocation , /*throttleLimit*/ 5 , host ) } ) ;
1943
1943
1944
1944
projectService . openClientFile ( f1 . path ) ;
1945
1945
projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
@@ -1987,4 +1987,52 @@ namespace ts.projectSystem {
1987
1987
assert . deepEqual ( s3 , newPerFileSettings , "file settings should still be the same with per-file settings" ) ;
1988
1988
} ) ;
1989
1989
} ) ;
1990
+
1991
+ describe ( "watching @types" , ( ) => {
1992
+ it ( "works correctly when typings are added or removed" , ( ) => {
1993
+ const f1 = {
1994
+ path : "/a/b/app.ts" ,
1995
+ content : "let x = 1;"
1996
+ } ;
1997
+ const t1 = {
1998
+ path : "/a/b/node_modules/@types/lib1/index.d.ts" ,
1999
+ content : "export let a: number"
2000
+ } ;
2001
+ const t2 = {
2002
+ path : "/a/b/node_modules/@types/lib2/index.d.ts" ,
2003
+ content : "export let b: number"
2004
+ } ;
2005
+ const tsconfig = {
2006
+ path : "/a/b/tsconfig.json" ,
2007
+ content : JSON . stringify ( {
2008
+ compilerOptions : { } ,
2009
+ exclude : [ "node_modules" ]
2010
+ } )
2011
+ } ;
2012
+ const host = createServerHost ( [ f1 , t1 , tsconfig ] ) ;
2013
+ const projectService = createProjectService ( host ) ;
2014
+
2015
+ projectService . openClientFile ( f1 . path ) ;
2016
+ projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
2017
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path , t1 . path ] ) ;
2018
+
2019
+ // delete t1
2020
+ host . reloadFS ( [ f1 , tsconfig ] ) ;
2021
+ host . triggerDirectoryWatcherCallback ( "/a/b/node_modules/@types" , "lib1" ) ;
2022
+ // run throttled operation
2023
+ host . runQueuedTimeoutCallbacks ( ) ;
2024
+
2025
+ projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
2026
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
2027
+
2028
+ // create t2
2029
+ host . reloadFS ( [ f1 , tsconfig , t2 ] ) ;
2030
+ host . triggerDirectoryWatcherCallback ( "/a/b/node_modules/@types" , "lib2" ) ;
2031
+ // run throttled operation
2032
+ host . runQueuedTimeoutCallbacks ( ) ;
2033
+
2034
+ projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
2035
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path , t2 . path ] ) ;
2036
+ } ) ;
2037
+ } ) ;
1990
2038
}
0 commit comments