@@ -244,7 +244,7 @@ namespace ts.projectSystem {
244244 checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
245245
246246 installer . installAll ( /*expectedCount*/ 0 ) ;
247- host . checkTimeoutQueueLengthAndRun ( 2 ) ;
247+ host . checkTimeoutQueueLength ( 0 ) ;
248248 checkNumberOfProjects ( projectService , { inferredProjects : 1 } ) ;
249249 // files should not be removed from project if ATA is skipped
250250 checkProjectActualFiles ( p , [ jqueryJs . path ] ) ;
@@ -1024,9 +1024,8 @@ namespace ts.projectSystem {
10241024 service . openClientFile ( f . path ) ;
10251025
10261026 installer . checkPendingCommands ( /*expectedCount*/ 0 ) ;
1027-
10281027 host . writeFile ( fixedPackageJson . path , fixedPackageJson . content ) ;
1029- host . checkTimeoutQueueLengthAndRun ( 2 ) ; // To refresh the project and refresh inferred projects
1028+ host . checkTimeoutQueueLength ( 0 ) ;
10301029 // expected install request
10311030 installer . installAll ( /*expectedCount*/ 1 ) ;
10321031 host . checkTimeoutQueueLengthAndRun ( 2 ) ;
@@ -1212,7 +1211,8 @@ namespace ts.projectSystem {
12121211 }
12131212 } ;
12141213 session . executeCommand ( changeRequest ) ;
1215- host . checkTimeoutQueueLengthAndRun ( 2 ) ; // This enqueues the updategraph and refresh inferred projects
1214+ host . checkTimeoutQueueLength ( 0 ) ;
1215+ proj . updateGraph ( ) ;
12161216 const version2 = proj . lastCachedUnresolvedImportsList ;
12171217 assert . strictEqual ( version1 , version2 , "set of unresolved imports should change" ) ;
12181218 } ) ;
@@ -1837,6 +1837,7 @@ namespace ts.projectSystem {
18371837 const appPath = "/a/b/app.js" as Path ;
18381838 const foooPath = "/a/b/node_modules/fooo/index.d.ts" ;
18391839 function verifyResolvedModuleOfFooo ( project : server . Project ) {
1840+ server . updateProjectIfDirty ( project ) ;
18401841 const foooResolution = project . getLanguageService ( ) . getProgram ( ) ! . getSourceFileByPath ( appPath ) ! . resolvedModules ! . get ( "fooo" ) ! ;
18411842 assert . equal ( foooResolution . resolvedFileName , foooPath ) ;
18421843 return foooResolution ;
@@ -1851,6 +1852,7 @@ namespace ts.projectSystem {
18511852 path : foooPath ,
18521853 content : `export var x: string;`
18531854 } ;
1855+
18541856 const host = createServerHost ( [ app , fooo ] ) ;
18551857 const installer = new ( class extends Installer {
18561858 constructor ( ) {
@@ -1873,6 +1875,17 @@ namespace ts.projectSystem {
18731875 checkProjectActualFiles ( proj , typingFiles . map ( f => f . path ) . concat ( app . path , fooo . path ) ) ;
18741876 const foooResolution2 = verifyResolvedModuleOfFooo ( proj ) ;
18751877 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 ) ) ;
18761889 }
18771890
18781891 it ( "correctly invalidate the resolutions with typing names" , ( ) => {
@@ -1883,6 +1896,10 @@ namespace ts.projectSystem {
18831896 } ) ;
18841897
18851898 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+ } ;
18861903 const fooAA : File = {
18871904 path : `${ globalTypingsCacheLocation } /node_modules/foo/a/a.d.ts` ,
18881905 content : "export function a (): void;"
@@ -1899,7 +1916,7 @@ namespace ts.projectSystem {
18991916 import * as a from "foo/a/a";
19001917 import * as b from "foo/a/b";
19011918 import * as c from "foo/a/c";
1902- ` , [ "foo" ] , [ fooAA , fooAB , fooAC ] ) ;
1919+ ` , [ "foo" ] , [ fooIndex , fooAA , fooAB , fooAC ] ) ;
19031920 } ) ;
19041921
19051922 it ( "should handle node core modules" , ( ) => {
@@ -1958,12 +1975,21 @@ declare module "stream" {
19581975 host . checkTimeoutQueueLengthAndRun ( 2 ) ;
19591976 checkProjectActualFiles ( proj , [ file . path , libFile . path , nodeTyping . path ] ) ;
19601977
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
19661989 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 ) ) ;
19671993 } ) ;
19681994 } ) ;
19691995
0 commit comments