@@ -674,5 +674,80 @@ fn5();
674674 ) ;
675675 } ) ;
676676 } ) ;
677+
678+ it ( "reusing d.ts files from composite and non composite projects" , ( ) => {
679+ const projectLocation = "/user/username/projects/myproject" ;
680+ const configA : File = {
681+ path : `${ projectLocation } /compositea/tsconfig.json` ,
682+ content : JSON . stringify ( {
683+ compilerOptions : {
684+ composite : true ,
685+ outDir : "../dist/" ,
686+ rootDir : "../" ,
687+ baseUrl : "../" ,
688+ paths : { "@ref/*" : [ "./dist/*" ] }
689+ }
690+ } )
691+ } ;
692+ const aTs : File = {
693+ path : `${ projectLocation } /compositea/a.ts` ,
694+ content : `import { b } from "@ref/compositeb/b";`
695+ } ;
696+ const a2Ts : File = {
697+ path : `${ projectLocation } /compositea/a2.ts` ,
698+ content : `export const x = 10;`
699+ } ;
700+ const configB : File = {
701+ path : `${ projectLocation } /compositeb/tsconfig.json` ,
702+ content : configA . content
703+ } ;
704+ const bTs : File = {
705+ path : `${ projectLocation } /compositeb/b.ts` ,
706+ content : "export function b() {}"
707+ } ;
708+ const bDts : File = {
709+ path : `${ projectLocation } /dist/compositeb/b.d.ts` ,
710+ content : "export declare function b(): void;"
711+ } ;
712+ const configC : File = {
713+ path : `${ projectLocation } /compositec/tsconfig.json` ,
714+ content : JSON . stringify ( {
715+ compilerOptions : {
716+ composite : true ,
717+ outDir : "../dist/" ,
718+ rootDir : "../" ,
719+ baseUrl : "../" ,
720+ paths : { "@ref/*" : [ "./*" ] }
721+ } ,
722+ references : [ { path : "../compositeb" } ]
723+ } )
724+ } ;
725+ const cTs : File = {
726+ path : `${ projectLocation } /compositec/c.ts` ,
727+ content : aTs . content
728+ } ;
729+ const files = [ libFile , aTs , a2Ts , configA , bDts , bTs , configB , cTs , configC ] ;
730+ const host = createServerHost ( files ) ;
731+ const service = createProjectService ( host ) ;
732+ service . openClientFile ( aTs . path ) ;
733+ service . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
734+
735+ // project A referencing b.d.ts without project reference
736+ const projectA = service . configuredProjects . get ( configA . path ) ! ;
737+ assert . isDefined ( projectA ) ;
738+ checkProjectActualFiles ( projectA , [ aTs . path , a2Ts . path , bDts . path , libFile . path , configA . path ] ) ;
739+
740+ // reuses b.d.ts but sets the path and resolved path since projectC has project references
741+ // as the real resolution was to b.ts
742+ service . openClientFile ( cTs . path ) ;
743+ service . checkNumberOfProjects ( { configuredProjects : 2 } ) ;
744+ const projectC = service . configuredProjects . get ( configC . path ) ! ;
745+ checkProjectActualFiles ( projectC , [ cTs . path , bDts . path , libFile . path , configC . path ] ) ;
746+
747+ // Now new project for project A tries to reuse b but there is no filesByName mapping for b's source location
748+ host . writeFile ( a2Ts . path , `${ a2Ts . content } export const y = 30;` ) ;
749+ assert . isTrue ( projectA . dirty ) ;
750+ projectA . updateGraph ( ) ;
751+ } ) ;
677752 } ) ;
678753}
0 commit comments