diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 8005aabcc3538..4e37395f41e50 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1345,7 +1345,7 @@ namespace ts { configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, - /*@internal*/ extendedConfigCache?: Map + extendedConfigCache?: Map ): ParsedCommandLine | undefined { let configFileText: string | undefined; try { @@ -2183,7 +2183,7 @@ namespace ts { return existingErrors !== configParseDiagnostics.length; } - interface ParsedTsconfig { + export interface ParsedTsconfig { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; @@ -2370,7 +2370,6 @@ namespace ts { return undefined; } - /*@internal*/ export interface ExtendedConfigCacheEntry { extendedResult: TsConfigSourceFile; extendedConfig: ParsedTsconfig | undefined; @@ -2398,7 +2397,6 @@ namespace ts { const extendedDirname = getDirectoryPath(extendedConfigPath); extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache); - if (isSuccessfulParsedTsconfig(extendedConfig)) { // Update the paths to reflect base path @@ -2423,7 +2421,7 @@ namespace ts { if (sourceFile) { sourceFile.extendedSourceFiles = [extendedResult.fileName]; if (extendedResult.extendedSourceFiles) { - sourceFile.extendedSourceFiles!.push(...extendedResult.extendedSourceFiles); + sourceFile.extendedSourceFiles.push(...extendedResult.extendedSourceFiles); } } if (extendedResult.parseDiagnostics.length) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9103ca2432d74..61030ed39feaf 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2682,10 +2682,12 @@ namespace ts { if (host.getParsedCommandLine) { commandLine = host.getParsedCommandLine(refPath); if (!commandLine) { + addFileToFilesByName(/*sourceFile*/ undefined, sourceFilePath, /*redirectedPath*/ undefined); projectReferenceRedirects.set(sourceFilePath, false); return undefined; } sourceFile = Debug.assertDefined(commandLine.options.configFile); + addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); } else { // An absolute path pointing to the containing directory of the config file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 36b1a32e54a6a..da5ab5a677263 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5130,7 +5130,7 @@ namespace ts { /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; /* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean; createHash?(data: string): string; - /*@internal*/getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; // TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesnt use compilerHost as base /*@internal*/createDirectory?(directory: string): void; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5d5472e840592..c0cc90efdc770 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2760,6 +2760,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3631,7 +3632,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3673,7 +3674,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, /*@internal*/ extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e8e2bed3bb8f9..61f5919396d74 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2760,6 +2760,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[]; getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } interface SourceMapRange extends TextRange { source?: SourceMapSource; @@ -3631,7 +3632,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost): ParsedCommandLine | undefined; + function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -3673,7 +3674,20 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray): ParsedCommandLine; + function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, /*@internal*/ extendedConfigCache?: Map): ParsedCommandLine; + interface ParsedTsconfig { + raw: any; + options?: CompilerOptions; + typeAcquisition?: TypeAcquisition; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; + } + interface ExtendedConfigCacheEntry { + extendedResult: TsConfigSourceFile; + extendedConfig: ParsedTsconfig | undefined; + } function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[];