@@ -1482,6 +1482,76 @@ var x = 10;`
1482
1482
) ;
1483
1483
} ) ;
1484
1484
1485
+ it ( "synchronizeProjectList provides updates to redirect info when requested" , ( ) => {
1486
+ const projectRootPath = "/users/username/projects/project" ;
1487
+ const fileA : File = {
1488
+ path : `${ projectRootPath } /A/a.ts` ,
1489
+ content : "export const foo: string = 5;"
1490
+ } ;
1491
+ const configA : File = {
1492
+ path : `${ projectRootPath } /A/tsconfig.json` ,
1493
+ content : `{
1494
+ "compilerOptions": {
1495
+ "composite": true,
1496
+ "declaration": true
1497
+ }
1498
+ }`
1499
+ } ;
1500
+ const fileB : File = {
1501
+ path : `${ projectRootPath } /B/b.ts` ,
1502
+ content : "import { foo } from \"../B/b2\"; console.log(foo);"
1503
+ } ;
1504
+ const fileB2 : File = {
1505
+ path : `${ projectRootPath } /B/b2.ts` ,
1506
+ content : "export const foo: string = 5;"
1507
+ } ;
1508
+ const configB : File = {
1509
+ path : `${ projectRootPath } /B/tsconfig.json` ,
1510
+ content : `{
1511
+ "compilerOptions": {
1512
+ "composite": true,
1513
+ "declaration": true
1514
+ },
1515
+ "references": [
1516
+ { "path": "../A" }
1517
+ ]
1518
+ }`
1519
+ } ;
1520
+ const files = [ fileA , fileB , fileB2 , configA , configB , libFile ] ;
1521
+ const host = createServerHost ( files ) ;
1522
+ const projectService = createProjectService ( host ) ;
1523
+ projectService . openClientFile ( fileA . path ) ;
1524
+ projectService . openClientFile ( fileB . path ) ;
1525
+ const knownProjects = projectService . synchronizeProjectList ( [ ] , /*includeProjectReferenceRedirectInfo*/ true ) ;
1526
+ assert ( knownProjects . length === 2 , `Expected 2 projects but received ${ knownProjects . length } ` ) ;
1527
+ assert ( knownProjects [ 0 ] . files ?. length === 3 , `Expected project A to have 3 files but received ${ knownProjects [ 0 ] . files ?. length } ` ) ;
1528
+ assert ( knownProjects [ 0 ] . files ?. every (
1529
+ ( file : string | protocol . FileWithProjectReferenceRedirectInfo ) =>
1530
+ typeof file === "object" && ! file . isSourceOfProjectReferenceRedirect ) ,
1531
+ `Expected every file in project A to not be redirected.`
1532
+ ) ;
1533
+ assert ( knownProjects [ 1 ] . files ?. length === 4 , `Expected project B to have 4 files but received ${ knownProjects [ 1 ] . files ?. length } ` ) ;
1534
+ assert ( knownProjects [ 1 ] . files ?. every (
1535
+ ( file : string | protocol . FileWithProjectReferenceRedirectInfo ) =>
1536
+ typeof file === "object" && ! file . isSourceOfProjectReferenceRedirect ) ,
1537
+ `Expected every file in project B to not be redirected.`
1538
+ ) ;
1539
+
1540
+ host . modifyFile ( configA . path , `{
1541
+ "compilerOptions": {
1542
+ "composite": true,
1543
+ "declaration": true
1544
+ },
1545
+ "include": [
1546
+ "**/*",
1547
+ "../B/b2.ts"
1548
+ ]
1549
+ }` ) ;
1550
+ const newKnownProjects = projectService . synchronizeProjectList ( knownProjects . map ( proj => proj . info ! ) , /*includeProjectReferenceRedirectInfo*/ true ) ;
1551
+ assert ( newKnownProjects [ 0 ] . changes ?. added . length === 1 , `Expected b2.ts to be added to project A` ) ;
1552
+ assert ( newKnownProjects [ 1 ] . changes ?. updatedRedirects ?. length === 1 , `Expected b2.ts to be updated in project B` ) ;
1553
+ } ) ;
1554
+
1485
1555
it ( "handles delayed directory watch invoke on file creation" , ( ) => {
1486
1556
const projectRootPath = "/users/username/projects/project" ;
1487
1557
const fileB : File = {
0 commit comments