@@ -2677,18 +2677,30 @@ namespace ts {
2677
2677
return fromCache || undefined ;
2678
2678
}
2679
2679
2680
- // An absolute path pointing to the containing directory of the config file
2681
- const basePath = getNormalizedAbsolutePath ( getDirectoryPath ( refPath ) , host . getCurrentDirectory ( ) ) ;
2682
- const sourceFile = host . getSourceFile ( refPath , ScriptTarget . JSON ) as JsonSourceFile | undefined ;
2683
- addFileToFilesByName ( sourceFile , sourceFilePath , /*redirectedPath*/ undefined ) ;
2684
- if ( sourceFile === undefined ) {
2685
- projectReferenceRedirects . set ( sourceFilePath , false ) ;
2686
- return undefined ;
2680
+ let commandLine : ParsedCommandLine | undefined ;
2681
+ let sourceFile : JsonSourceFile | undefined ;
2682
+ if ( host . getParsedCommandLine ) {
2683
+ commandLine = host . getParsedCommandLine ( refPath ) ;
2684
+ if ( ! commandLine ) {
2685
+ projectReferenceRedirects . set ( sourceFilePath , false ) ;
2686
+ return undefined ;
2687
+ }
2688
+ sourceFile = Debug . assertDefined ( commandLine . options . configFile ) ;
2689
+ }
2690
+ else {
2691
+ // An absolute path pointing to the containing directory of the config file
2692
+ const basePath = getNormalizedAbsolutePath ( getDirectoryPath ( refPath ) , host . getCurrentDirectory ( ) ) ;
2693
+ sourceFile = host . getSourceFile ( refPath , ScriptTarget . JSON ) as JsonSourceFile | undefined ;
2694
+ addFileToFilesByName ( sourceFile , sourceFilePath , /*redirectedPath*/ undefined ) ;
2695
+ if ( sourceFile === undefined ) {
2696
+ projectReferenceRedirects . set ( sourceFilePath , false ) ;
2697
+ return undefined ;
2698
+ }
2699
+ sourceFile . path = sourceFilePath ;
2700
+ sourceFile . resolvedPath = sourceFilePath ;
2701
+ sourceFile . originalFileName = refPath ;
2702
+ commandLine = parseJsonSourceFileConfigFileContent ( sourceFile , configParsingHost , basePath , /*existingOptions*/ undefined , refPath ) ;
2687
2703
}
2688
- sourceFile . path = sourceFilePath ;
2689
- sourceFile . resolvedPath = sourceFilePath ;
2690
- sourceFile . originalFileName = refPath ;
2691
- const commandLine = parseJsonSourceFileConfigFileContent ( sourceFile , configParsingHost , basePath , /*existingOptions*/ undefined , refPath ) ;
2692
2704
const resolvedRef : ResolvedProjectReference = { commandLine, sourceFile } ;
2693
2705
projectReferenceRedirects . set ( sourceFilePath , resolvedRef ) ;
2694
2706
if ( commandLine . projectReferences ) {
0 commit comments