mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
Merge pull request #27139 from ajafff/config-extends
fix getExtendedConfig in commandLineParser
This commit is contained in:
commit
577ee49106
@ -2030,7 +2030,7 @@ namespace ts {
|
||||
if (ownConfig.extendedConfigPath) {
|
||||
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
|
||||
resolutionStack = resolutionStack.concat([resolvedPath]);
|
||||
const extendedConfig = getExtendedConfig(sourceFile!, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors);
|
||||
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors);
|
||||
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
|
||||
const baseRaw = extendedConfig.raw;
|
||||
const raw = ownConfig.raw;
|
||||
@ -2171,7 +2171,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getExtendedConfig(
|
||||
sourceFile: TsConfigSourceFile,
|
||||
sourceFile: TsConfigSourceFile | undefined,
|
||||
extendedConfigPath: string,
|
||||
host: ParseConfigHost,
|
||||
basePath: string,
|
||||
@ -2180,7 +2180,7 @@ namespace ts {
|
||||
): ParsedTsconfig | undefined {
|
||||
const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
|
||||
if (sourceFile) {
|
||||
(sourceFile.extendedSourceFiles || (sourceFile.extendedSourceFiles = [])).push(extendedResult.fileName);
|
||||
sourceFile.extendedSourceFiles = [extendedResult.fileName];
|
||||
}
|
||||
if (extendedResult.parseDiagnostics.length) {
|
||||
errors.push(...extendedResult.parseDiagnostics);
|
||||
@ -2190,8 +2190,8 @@ namespace ts {
|
||||
const extendedDirname = getDirectoryPath(extendedConfigPath);
|
||||
const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname,
|
||||
getBaseFileName(extendedConfigPath), resolutionStack, errors);
|
||||
if (sourceFile) {
|
||||
sourceFile.extendedSourceFiles!.push(...extendedResult.extendedSourceFiles!);
|
||||
if (sourceFile && extendedResult.extendedSourceFiles) {
|
||||
sourceFile.extendedSourceFiles!.push(...extendedResult.extendedSourceFiles);
|
||||
}
|
||||
|
||||
if (isSuccessfulParsedTsconfig(extendedConfig)) {
|
||||
|
||||
@ -244,6 +244,20 @@ namespace ts {
|
||||
}, [
|
||||
combinePaths(basePath, "main.ts")
|
||||
]);
|
||||
|
||||
it("adds extendedSourceFiles only once", () => {
|
||||
const sourceFile = readJsonConfigFile("configs/fourth.json", (path) => host.readFile(path));
|
||||
const dir = combinePaths(basePath, "configs");
|
||||
const expected = [
|
||||
combinePaths(dir, "third.json"),
|
||||
combinePaths(dir, "second.json"),
|
||||
combinePaths(dir, "base.json"),
|
||||
];
|
||||
parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
|
||||
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
|
||||
parseJsonSourceFileConfigFileContent(sourceFile, host, dir, {}, "fourth.json");
|
||||
assert.deepEqual(sourceFile.extendedSourceFiles, expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user