@@ -706,5 +706,80 @@ fn5();
706
706
verifyScenarios ( /*withRefs*/ false ) ;
707
707
verifyScenarios ( /*withRefs*/ true ) ;
708
708
} ) ;
709
+
710
+ it ( "reusing d.ts files from composite and non composite projects" , ( ) => {
711
+ const projectLocation = "/user/username/projects/myproject" ;
712
+ const configA : File = {
713
+ path : `${ projectLocation } /compositea/tsconfig.json` ,
714
+ content : JSON . stringify ( {
715
+ compilerOptions : {
716
+ composite : true ,
717
+ outDir : "../dist/" ,
718
+ rootDir : "../" ,
719
+ baseUrl : "../" ,
720
+ paths : { "@ref/*" : [ "./dist/*" ] }
721
+ }
722
+ } )
723
+ } ;
724
+ const aTs : File = {
725
+ path : `${ projectLocation } /compositea/a.ts` ,
726
+ content : `import { b } from "@ref/compositeb/b";`
727
+ } ;
728
+ const a2Ts : File = {
729
+ path : `${ projectLocation } /compositea/a2.ts` ,
730
+ content : `export const x = 10;`
731
+ } ;
732
+ const configB : File = {
733
+ path : `${ projectLocation } /compositeb/tsconfig.json` ,
734
+ content : configA . content
735
+ } ;
736
+ const bTs : File = {
737
+ path : `${ projectLocation } /compositeb/b.ts` ,
738
+ content : "export function b() {}"
739
+ } ;
740
+ const bDts : File = {
741
+ path : `${ projectLocation } /dist/compositeb/b.d.ts` ,
742
+ content : "export declare function b(): void;"
743
+ } ;
744
+ const configC : File = {
745
+ path : `${ projectLocation } /compositec/tsconfig.json` ,
746
+ content : JSON . stringify ( {
747
+ compilerOptions : {
748
+ composite : true ,
749
+ outDir : "../dist/" ,
750
+ rootDir : "../" ,
751
+ baseUrl : "../" ,
752
+ paths : { "@ref/*" : [ "./*" ] }
753
+ } ,
754
+ references : [ { path : "../compositeb" } ]
755
+ } )
756
+ } ;
757
+ const cTs : File = {
758
+ path : `${ projectLocation } /compositec/c.ts` ,
759
+ content : aTs . content
760
+ } ;
761
+ const files = [ libFile , aTs , a2Ts , configA , bDts , bTs , configB , cTs , configC ] ;
762
+ const host = createServerHost ( files ) ;
763
+ const service = createProjectService ( host ) ;
764
+ service . openClientFile ( aTs . path ) ;
765
+ service . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
766
+
767
+ // project A referencing b.d.ts without project reference
768
+ const projectA = service . configuredProjects . get ( configA . path ) ! ;
769
+ assert . isDefined ( projectA ) ;
770
+ checkProjectActualFiles ( projectA , [ aTs . path , a2Ts . path , bDts . path , libFile . path , configA . path ] ) ;
771
+
772
+ // reuses b.d.ts but sets the path and resolved path since projectC has project references
773
+ // as the real resolution was to b.ts
774
+ service . openClientFile ( cTs . path ) ;
775
+ service . checkNumberOfProjects ( { configuredProjects : 2 } ) ;
776
+ const projectC = service . configuredProjects . get ( configC . path ) ! ;
777
+ checkProjectActualFiles ( projectC , [ cTs . path , bDts . path , libFile . path , configC . path ] ) ;
778
+
779
+ // Now new project for project A tries to reuse b but there is no filesByName mapping for b's source location
780
+ host . writeFile ( a2Ts . path , `${ a2Ts . content } export const y = 30;` ) ;
781
+ assert . isTrue ( projectA . dirty ) ;
782
+ projectA . updateGraph ( ) ;
783
+ } ) ;
709
784
} ) ;
710
785
}
0 commit comments