66
77namespace ts . projectSystem {
88 const nullCancellationToken = server . nullCancellationToken ;
9- import libFile = ts . TestFSWithWatch . libFile ;
10- import FileOrFolder = ts . TestFSWithWatch . FileOrFolder ;
119
1210 function createTestTypingsInstaller ( host : server . ServerHost ) {
1311 return new TestTypingsInstaller ( "/a/data/" , /*throttleLimit*/ 5 , host ) ;
@@ -16,7 +14,7 @@ namespace ts.projectSystem {
1614 describe ( "CompileOnSave affected list" , ( ) => {
1715 interface ProjectFileList {
1816 projectFileName : string ;
19- files : ( string | FileOrFolder | vfs . VirtualFile ) [ ] ;
17+ files : ( string | vfs . VirtualFile ) [ ] ;
2018 }
2119
2220 function sendAffectedFileRequestAndCheckResult ( session : server . Session , args : server . protocol . FileRequestArgs , expectedFileList : ProjectFileList | ProjectFileList [ ] ) {
@@ -64,14 +62,13 @@ namespace ts.projectSystem {
6462
6563 describe ( "for configured projects" , ( ) => {
6664 it ( "should contains only itself if a module file's shape didn't change, and all files referencing it if its shape changed" , ( ) => {
67- const host = new fakes . FakeServerHost ( ) ;
65+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
6866 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
6967 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
7068 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
7169 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
7270 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
7371 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
74- host . vfs . addFile ( libFile . path , libFile . content ) ;
7572
7673 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
7774
@@ -111,14 +108,13 @@ namespace ts.projectSystem {
111108 } ) ;
112109
113110 it ( "should be up-to-date with the reference map changes" , ( ) => {
114- const host = new fakes . FakeServerHost ( ) ;
111+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
115112 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
116113 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
117114 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
118115 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
119116 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
120117 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
121- host . vfs . addFile ( libFile . path , libFile . content ) ;
122118
123119 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
124120
@@ -178,14 +174,13 @@ namespace ts.projectSystem {
178174 } ) ;
179175
180176 it ( "should be up-to-date with changes made in non-open files" , ( ) => {
181- const host = new fakes . FakeServerHost ( ) ;
177+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
182178 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
183179 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
184180 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
185181 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
186182 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
187183 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
188- host . vfs . addFile ( libFile . path , libFile . content ) ;
189184
190185 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
191186
@@ -213,14 +208,13 @@ namespace ts.projectSystem {
213208 } ) ;
214209
215210 it ( "should be up-to-date with deleted files" , ( ) => {
216- const host = new fakes . FakeServerHost ( ) ;
211+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
217212 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
218213 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
219214 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
220215 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
221216 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
222217 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
223- host . vfs . addFile ( libFile . path , libFile . content ) ;
224218
225219 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
226220
@@ -247,14 +241,13 @@ namespace ts.projectSystem {
247241 } ) ;
248242
249243 it ( "should be up-to-date with newly created files" , ( ) => {
250- const host = new fakes . FakeServerHost ( ) ;
244+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
251245 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
252246 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
253247 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
254248 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
255249 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
256250 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
257- host . vfs . addFile ( libFile . path , libFile . content ) ;
258251
259252 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
260253
@@ -281,11 +274,10 @@ namespace ts.projectSystem {
281274 } ) ;
282275
283276 it ( "should detect changes in non-root files" , ( ) => {
284- const host = new fakes . FakeServerHost ( ) ;
277+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
285278 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
286279 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; let y = Foo();` ) ;
287280 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ "compileOnSave": true, "files": ["${ file1Consumer1 . path } "] }` ) ;
288- host . vfs . addFile ( libFile . path , libFile . content ) ;
289281
290282 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
291283
@@ -325,14 +317,13 @@ namespace ts.projectSystem {
325317 } ) ;
326318
327319 it ( "should return all files if a global file changed shape" , ( ) => {
328- const host = new fakes . FakeServerHost ( ) ;
320+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
329321 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
330322 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
331323 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
332324 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
333325 const globalFile3 = host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
334326 const moduleFile2 = host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
335- host . vfs . addFile ( libFile . path , libFile . content ) ;
336327
337328 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
338329
@@ -354,14 +345,13 @@ namespace ts.projectSystem {
354345 } ) ;
355346
356347 it ( "should return empty array if CompileOnSave is not enabled" , ( ) => {
357- const host = new fakes . FakeServerHost ( ) ;
348+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
358349 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{}` ) ;
359350 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
360351 host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
361352 host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
362353 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
363354 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
364- host . vfs . addFile ( libFile . path , libFile . content ) ;
365355
366356 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
367357
@@ -373,14 +363,13 @@ namespace ts.projectSystem {
373363 } ) ;
374364
375365 it ( "should save when compileOnSave is enabled in base tsconfig.json" , ( ) => {
376- const host = new fakes . FakeServerHost ( ) ;
366+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
377367 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ "extends": "/a/tsconfig.json" }` ) ;
378368 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
379369 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
380370 const file1Consumer2 = host . vfs . addFile ( "/a/b/file1Consumer2.ts" , `import {Foo} from "./moduleFile1"; let z = 10;` ) ;
381371 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
382372 host . vfs . addFile ( "/a/b/moduleFile2.ts" , `export var Foo4 = 10;` ) ;
383- host . vfs . addFile ( libFile . path , libFile . content ) ;
384373 host . vfs . addFile ( "/a/tsconfig.json" , `{ "compileOnSave": true }` ) ;
385374
386375 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
@@ -393,11 +382,10 @@ namespace ts.projectSystem {
393382 } ) ;
394383
395384 it ( "should always return the file itself if '--isolatedModules' is specified" , ( ) => {
396- const host = new fakes . FakeServerHost ( ) ;
385+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
397386 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ "compileOnSave": true, "compilerOptions": { "isolatedModules": true } }` ) ;
398387 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
399388 host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
400- host . vfs . addFile ( libFile . path , libFile . content ) ;
401389
402390 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
403391
@@ -418,11 +406,10 @@ namespace ts.projectSystem {
418406 } ) ;
419407
420408 it ( "should always return the file itself if '--out' or '--outFile' is specified" , ( ) => {
421- const host = new fakes . FakeServerHost ( ) ;
409+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
422410 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ "compileOnSave": true, "compilerOptions": { "module": "system", "outFile": "/a/b/out.js" } }` ) ;
423411 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
424412 host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
425- host . vfs . addFile ( libFile . path , libFile . content ) ;
426413
427414 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
428415
@@ -443,13 +430,12 @@ namespace ts.projectSystem {
443430 } ) ;
444431
445432 it ( "should return cascaded affected file list" , ( ) => {
446- const host = new fakes . FakeServerHost ( ) ;
433+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
447434 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{ compileOnSave": true }` ) ;
448435 const moduleFile1 = host . vfs . addFile ( "/a/b/moduleFile1.ts" , `export function Foo() { };` ) ;
449436 const file1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1.ts" , `import {Foo} from "./moduleFile1"; export var y = 10;` ) ;
450437 const file1Consumer1Consumer1 = host . vfs . addFile ( "/a/b/file1Consumer1Consumer1.ts" , `import {y} from "./file1Consumer1";` ) ;
451438 host . vfs . addFile ( "/a/b/globalFile3.ts" , `interface GlobalFoo { age: number }` ) ;
452- host . vfs . addFile ( libFile . path , libFile . content ) ;
453439
454440 const session = createSession ( host , createTestTypingsInstaller ( host ) ) ;
455441
@@ -574,11 +560,10 @@ namespace ts.projectSystem {
574560 } ) ;
575561
576562 it ( "should emit specified file" , ( ) => {
577- const host = new fakes . FakeServerHost ( { newLine : "\r\n" } ) ;
563+ const host = new fakes . FakeServerHost ( { lib : true , newLine : "\r\n" } ) ;
578564 const file1 = host . vfs . addFile ( "/a/b/f1.ts" , `export function Foo() { return 10; }` ) ;
579565 const file2 = host . vfs . addFile ( "/a/b/f2.ts" , `import {Foo} from "./f1"; let y = Foo();` ) ;
580566 const configFile = host . vfs . addFile ( "/a/b/tsconfig.json" , `{}` ) ;
581- host . vfs . addFile ( libFile . path , libFile . content ) ;
582567
583568 const typingsInstaller = createTestTypingsInstaller ( host ) ;
584569 const session = createSession ( host , { typingsInstaller } ) ;
@@ -595,12 +580,11 @@ namespace ts.projectSystem {
595580 it ( "shoud not emit js files in external projects" , ( ) => {
596581 const externalProjectName = "/a/b/externalproject" ;
597582
598- const host = new fakes . FakeServerHost ( ) ;
583+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
599584 const file1 = host . vfs . addFile ( "/a/b/file1.ts" , `consonle.log('file1');` ) ;
600585 // file2 has errors. The emit should not be blocked.
601586 const file2 = host . vfs . addFile ( "/a/b/file2.js" , `console.log'file2');` ) ;
602587 const file3 = host . vfs . addFile ( "/a/b/file3.js" , `console.log('file3');` ) ;
603- host . vfs . addFile ( libFile . path , libFile . content ) ;
604588
605589 const session = createSession ( host ) ;
606590 const projectService = session . getProjectService ( ) ;
@@ -628,9 +612,8 @@ namespace ts.projectSystem {
628612 it ( "should use project root as current directory so that compile on save results in correct file mapping" , ( ) => {
629613 const externalProjectName = "/root/TypeScriptProject3/TypeScriptProject3/TypeScriptProject3.csproj" ;
630614
631- const host = new fakes . FakeServerHost ( ) ;
615+ const host = new fakes . FakeServerHost ( { lib : true } ) ;
632616 const file1 = host . vfs . addFile ( "/root/TypeScriptProject3/TypeScriptProject3/Foo.ts" , `consonle.log('file1');` ) ;
633- host . vfs . addFile ( libFile . path , libFile . content ) ;
634617
635618 const session = createSession ( host ) ;
636619 const projectService = session . getProjectService ( ) ;
0 commit comments