@@ -1428,6 +1428,57 @@ var x = 10;`
1428
1428
host . checkTimeoutQueueLength ( 0 ) ;
1429
1429
} ) ;
1430
1430
1431
+ it ( "synchronizeProjectList provides redirect info when requested" , ( ) => {
1432
+ const projectRootPath = "/users/username/projects/project" ;
1433
+ const fileA : File = {
1434
+ path : `${ projectRootPath } /A/a.ts` ,
1435
+ content : "export const foo: string = 5;"
1436
+ } ;
1437
+ const configA : File = {
1438
+ path : `${ projectRootPath } /A/tsconfig.json` ,
1439
+ content : `{
1440
+ "compilerOptions": {
1441
+ "composite": true,
1442
+ "declaration": true
1443
+ }
1444
+ }`
1445
+ } ;
1446
+ const fileB : File = {
1447
+ path : `${ projectRootPath } /B/b.ts` ,
1448
+ content : "import { foo } from \"../A/a\"; console.log(foo);"
1449
+ } ;
1450
+ const configB : File = {
1451
+ path : `${ projectRootPath } /B/tsconfig.json` ,
1452
+ content : `{
1453
+ "compilerOptions": {
1454
+ "composite": true,
1455
+ "declaration": true
1456
+ },
1457
+ "references": [
1458
+ { "path": "../A" }
1459
+ ]
1460
+ }`
1461
+ } ;
1462
+ const files = [ fileA , fileB , configA , configB , libFile ] ;
1463
+ const host = createServerHost ( files ) ;
1464
+ const projectService = createProjectService ( host ) ;
1465
+ projectService . openClientFile ( fileA . path ) ;
1466
+ projectService . openClientFile ( fileB . path ) ;
1467
+ const knownProjects = projectService . synchronizeProjectList ( [ ] , /*includeProjectReferenceRedirectInfo*/ true ) ;
1468
+ assert ( knownProjects . length === 2 , `Expected 2 projects but received ${ knownProjects . length } ` ) ;
1469
+ assert ( knownProjects [ 0 ] . files ?. length === 3 , `Expected project A to have 3 files but received ${ knownProjects [ 0 ] . files ?. length } ` ) ;
1470
+ assert ( knownProjects [ 0 ] . files ?. every (
1471
+ ( file : string | protocol . FileWithProjectReferenceRedirectInfo ) =>
1472
+ typeof file === "object" && ! file . isSourceOfProjectReferenceRedirect ) ,
1473
+ `Expected every file in project A to not be redirected.`
1474
+ ) ;
1475
+ assert ( knownProjects [ 1 ] . files ?. length === 4 , `Expected project B to have 4 files but received ${ knownProjects [ 1 ] . files ?. length } ` ) ;
1476
+ knownProjects [ 1 ] . files ?. forEach (
1477
+ ( file : string | protocol . FileWithProjectReferenceRedirectInfo ) =>
1478
+ assert ( typeof file === "object" && ( ! file . isSourceOfProjectReferenceRedirect || file . fileName === fileA . path ) )
1479
+ ) ;
1480
+ } ) ;
1481
+
1431
1482
it ( "handles delayed directory watch invoke on file creation" , ( ) => {
1432
1483
const projectRootPath = "/users/username/projects/project" ;
1433
1484
const fileB : File = {
0 commit comments