@@ -189,7 +189,10 @@ namespace ts {
189189 getEnvironmentVariable : name => sys . getEnvironmentVariable ? sys . getEnvironmentVariable ( name ) : "" ,
190190 getDirectories : ( path : string ) => sys . getDirectories ( path ) ,
191191 realpath,
192- readDirectory : ( path , extensions , include , exclude , depth ) => sys . readDirectory ( path , extensions , include , exclude , depth )
192+ readDirectory : ( path , extensions , include , exclude , depth ) => sys . readDirectory ( path , extensions , include , exclude , depth ) ,
193+ getModifiedTime : sys . getModifiedTime && ( path => sys . getModifiedTime ! ( path ) ) ,
194+ setModifiedTime : sys . setModifiedTime && ( ( path , date ) => sys . setModifiedTime ! ( path , date ) ) ,
195+ deleteFile : sys . deleteFile && ( path => sys . deleteFile ! ( path ) )
193196 } ;
194197 }
195198
@@ -615,25 +618,27 @@ namespace ts {
615618 // A parallel array to projectReferences storing the results of reading in the referenced tsconfig files
616619 const resolvedProjectReferences : ( ResolvedProjectReference | undefined ) [ ] | undefined = projectReferences ? [ ] : undefined ;
617620 const projectReferenceRedirects : Map < string > = createMap ( ) ;
618- if ( projectReferences ) {
619- for ( const ref of projectReferences ) {
620- const parsedRef = parseProjectReferenceConfigFile ( ref ) ;
621- resolvedProjectReferences ! . push ( parsedRef ) ;
622- if ( parsedRef ) {
623- if ( parsedRef . commandLine . options . outFile ) {
624- const dtsOutfile = changeExtension ( parsedRef . commandLine . options . outFile , ".d.ts" ) ;
625- processSourceFile ( dtsOutfile , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false , /*packageId*/ undefined ) ;
626- }
627- addProjectReferenceRedirects ( parsedRef . commandLine , projectReferenceRedirects ) ;
628- }
629- }
630- }
631621
632622 const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles ( oldProgram , options ) ;
633623 const structuralIsReused = tryReuseStructureFromOldProgram ( ) ;
634624 if ( structuralIsReused !== StructureIsReused . Completely ) {
635625 processingDefaultLibFiles = [ ] ;
636626 processingOtherFiles = [ ] ;
627+
628+ if ( projectReferences ) {
629+ for ( const ref of projectReferences ) {
630+ const parsedRef = parseProjectReferenceConfigFile ( ref ) ;
631+ resolvedProjectReferences ! . push ( parsedRef ) ;
632+ if ( parsedRef ) {
633+ if ( parsedRef . commandLine . options . outFile ) {
634+ const dtsOutfile = changeExtension ( parsedRef . commandLine . options . outFile , ".d.ts" ) ;
635+ processSourceFile ( dtsOutfile , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false , /*packageId*/ undefined ) ;
636+ }
637+ addProjectReferenceRedirects ( parsedRef . commandLine , projectReferenceRedirects ) ;
638+ }
639+ }
640+ }
641+
637642 forEach ( rootNames , name => processRootFile ( name , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false ) ) ;
638643
639644 // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
@@ -1021,7 +1026,7 @@ namespace ts {
10211026
10221027 for ( const oldSourceFile of oldSourceFiles ) {
10231028 let newSourceFile = host . getSourceFileByPath
1024- ? host . getSourceFileByPath ( oldSourceFile . fileName , oldSourceFile . path , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile )
1029+ ? host . getSourceFileByPath ( oldSourceFile . fileName , oldSourceFile . resolvedPath || oldSourceFile . path , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile )
10251030 : host . getSourceFile ( oldSourceFile . fileName , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile ) ; // TODO: GH#18217
10261031
10271032 if ( ! newSourceFile ) {
@@ -1234,8 +1239,10 @@ namespace ts {
12341239
12351240 const dtsFilename = changeExtension ( resolvedRefOpts . options . outFile , ".d.ts" ) ;
12361241 const js = host . readFile ( resolvedRefOpts . options . outFile ) || `/* Input file ${ resolvedRefOpts . options . outFile } was missing */\r\n` ;
1242+ const jsMap = host . readFile ( resolvedRefOpts . options . outFile + ".map" ) ; // TODO: try to read sourceMappingUrl comment from the js file
12371243 const dts = host . readFile ( dtsFilename ) || `/* Input file ${ dtsFilename } was missing */\r\n` ;
1238- const node = createInputFiles ( js , dts ) ;
1244+ const dtsMap = host . readFile ( dtsFilename + ".map" ) ;
1245+ const node = createInputFiles ( js , dts , jsMap , dtsMap ) ;
12391246 nodes . push ( node ) ;
12401247 }
12411248 }
@@ -2047,6 +2054,7 @@ namespace ts {
20472054 if ( file ) {
20482055 sourceFilesFoundSearchingNodeModules . set ( path , currentNodeModulesDepth > 0 ) ;
20492056 file . path = path ;
2057+ file . resolvedPath = toPath ( fileName ) ;
20502058
20512059 if ( host . useCaseSensitiveFileNames ( ) ) {
20522060 const pathLowerCase = path . toLowerCase ( ) ;
@@ -2781,7 +2789,7 @@ namespace ts {
27812789 /**
27822790 * Returns the target config filename of a project reference
27832791 */
2784- function resolveProjectReferencePath ( host : CompilerHost , ref : ProjectReference ) : string | undefined {
2792+ export function resolveProjectReferencePath ( host : CompilerHost , ref : ProjectReference ) : string | undefined {
27852793 if ( ! host . fileExists ( ref . path ) ) {
27862794 return combinePaths ( ref . path , "tsconfig.json" ) ;
27872795 }
0 commit comments