@@ -244,7 +244,7 @@ namespace ts.projectSystem {
244
244
checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
245
245
246
246
installer . installAll ( /*expectedCount*/ 0 ) ;
247
- host . checkTimeoutQueueLengthAndRun ( 2 ) ;
247
+ host . checkTimeoutQueueLength ( 0 ) ;
248
248
checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
249
249
// files should not be removed from project if ATA is skipped
250
250
checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
@@ -1024,9 +1024,8 @@ namespace ts.projectSystem {
1024
1024
service . openClientFile ( f . path ) ;
1025
1025
1026
1026
installer . checkPendingCommands ( /*expectedCount*/ 0 ) ;
1027
-
1028
1027
host . writeFile ( fixedPackageJson . path , fixedPackageJson . content ) ;
1029
- host . checkTimeoutQueueLengthAndRun ( 2 ) ; // To refresh the project and refresh inferred projects
1028
+ host . checkTimeoutQueueLength ( 0 ) ;
1030
1029
// expected install request
1031
1030
installer . installAll ( /*expectedCount*/ 1 ) ;
1032
1031
host . checkTimeoutQueueLengthAndRun ( 2 ) ;
@@ -1212,7 +1211,8 @@ namespace ts.projectSystem {
1212
1211
}
1213
1212
} ;
1214
1213
session . executeCommand ( changeRequest ) ;
1215
- host . checkTimeoutQueueLengthAndRun ( 2 ) ; // This enqueues the updategraph and refresh inferred projects
1214
+ host . checkTimeoutQueueLength ( 0 ) ;
1215
+ proj . updateGraph ( ) ;
1216
1216
const version2 = proj . lastCachedUnresolvedImportsList ;
1217
1217
assert . strictEqual ( version1 , version2 , "set of unresolved imports should change" ) ;
1218
1218
} ) ;
@@ -1837,6 +1837,7 @@ namespace ts.projectSystem {
1837
1837
const appPath = "/a/b/app.js" as Path ;
1838
1838
const foooPath = "/a/b/node_modules/fooo/index.d.ts" ;
1839
1839
function verifyResolvedModuleOfFooo ( project : server . Project ) {
1840
+ server . updateProjectIfDirty ( project ) ;
1840
1841
const foooResolution = project . getLanguageService ( ) . getProgram ( ) ! . getSourceFileByPath ( appPath ) ! . resolvedModules ! . get ( "fooo" ) ! ;
1841
1842
assert . equal ( foooResolution . resolvedFileName , foooPath ) ;
1842
1843
return foooResolution ;
@@ -1851,6 +1852,7 @@ namespace ts.projectSystem {
1851
1852
path : foooPath ,
1852
1853
content : `export var x: string;`
1853
1854
} ;
1855
+
1854
1856
const host = createServerHost ( [ app , fooo ] ) ;
1855
1857
const installer = new ( class extends Installer {
1856
1858
constructor ( ) {
@@ -1873,6 +1875,17 @@ namespace ts.projectSystem {
1873
1875
checkProjectActualFiles ( proj , typingFiles . map ( f => f . path ) . concat ( app . path , fooo . path ) ) ;
1874
1876
const foooResolution2 = verifyResolvedModuleOfFooo ( proj ) ;
1875
1877
assert . strictEqual ( foooResolution1 , foooResolution2 ) ;
1878
+ projectService . applyChangesInOpenFiles ( /*openFiles*/ undefined , arrayIterator ( [ {
1879
+ fileName : app . path ,
1880
+ changes : arrayIterator ( [ {
1881
+ span : { start : 0 , length : 0 } ,
1882
+ newText : `import * as bar from "bar";`
1883
+ } ] )
1884
+ } ] ) ) ;
1885
+ host . runQueuedTimeoutCallbacks ( ) ; // Update the graph
1886
+ // Update the typing
1887
+ host . checkTimeoutQueueLength ( 0 ) ;
1888
+ assert . isFalse ( proj . resolutionCache . isFileWithInvalidatedNonRelativeUnresolvedImports ( app . path as Path ) ) ;
1876
1889
}
1877
1890
1878
1891
it ( "correctly invalidate the resolutions with typing names" , ( ) => {
@@ -1883,6 +1896,10 @@ namespace ts.projectSystem {
1883
1896
} ) ;
1884
1897
1885
1898
it ( "correctly invalidate the resolutions with typing names that are trimmed" , ( ) => {
1899
+ const fooIndex : File = {
1900
+ path : `${ globalTypingsCacheLocation } /node_modules/foo/index.d.ts` ,
1901
+ content : "export function aa(): void;"
1902
+ } ;
1886
1903
const fooAA : File = {
1887
1904
path : `${ globalTypingsCacheLocation } /node_modules/foo/a/a.d.ts` ,
1888
1905
content : "export function a (): void;"
@@ -1899,7 +1916,7 @@ namespace ts.projectSystem {
1899
1916
import * as a from "foo/a/a";
1900
1917
import * as b from "foo/a/b";
1901
1918
import * as c from "foo/a/c";
1902
- ` , [ "foo" ] , [ fooAA , fooAB , fooAC ] ) ;
1919
+ ` , [ "foo" ] , [ fooIndex , fooAA , fooAB , fooAC ] ) ;
1903
1920
} ) ;
1904
1921
1905
1922
it ( "should handle node core modules" , ( ) => {
@@ -1958,12 +1975,21 @@ declare module "stream" {
1958
1975
host . checkTimeoutQueueLengthAndRun ( 2 ) ;
1959
1976
checkProjectActualFiles ( proj , [ file . path , libFile . path , nodeTyping . path ] ) ;
1960
1977
1961
- // Here, since typings doesnt contain node typings and resolution fails and
1962
- // node typings go out of project,
1963
- // but because we handle core node modules when resolving from typings cache
1964
- // node typings are included in the project
1965
- host . checkTimeoutQueueLengthAndRun ( 2 ) ;
1978
+ // Here, since typings dont change, there is no timeout scheduled
1979
+ host . checkTimeoutQueueLength ( 0 ) ;
1980
+ checkProjectActualFiles ( proj , [ file . path , libFile . path , nodeTyping . path ] ) ;
1981
+ projectService . applyChangesInOpenFiles ( /*openFiles*/ undefined , arrayIterator ( [ {
1982
+ fileName : file . path ,
1983
+ changes : arrayIterator ( [ {
1984
+ span : { start : file . content . indexOf ( "const" ) , length : 0 } ,
1985
+ newText : `const bar = require("bar");`
1986
+ } ] )
1987
+ } ] ) ) ;
1988
+ proj . updateGraph ( ) ; // Update the graph
1966
1989
checkProjectActualFiles ( proj , [ file . path , libFile . path , nodeTyping . path ] ) ;
1990
+ // Update the typing
1991
+ host . checkTimeoutQueueLength ( 0 ) ;
1992
+ assert . isFalse ( proj . resolutionCache . isFileWithInvalidatedNonRelativeUnresolvedImports ( file . path as Path ) ) ;
1967
1993
} ) ;
1968
1994
} ) ;
1969
1995
0 commit comments