Fix(51828): extends field in tsconfig.json does nothing with empty string (#51981)

This commit is contained in:
navya9singh authored and GitHub committed 2023-01-17 12:31:23 -08:00
1 parent 9c9d4b029d
commit f6fc444b33
4 files changed
+27 -3

No files matched your search

+8 -3
View File
@@ -3279,7 +3279,7 @@ function parseOwnConfigOfJson(
json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
let extendedConfigPath: string | string[] | undefined;
if (json.extends) {
if (json.extends || json.extends === "") {
if (!isCompilerOptionsValue(extendsOptionDeclaration, json.extends)) {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", getCompilerOptionValueTypeString(extendsOptionDeclaration)));
}
@@ -3293,7 +3293,7 @@ function parseOwnConfigOfJson(
for (const fileName of json.extends as unknown[]) {
if (isString(fileName)) {
extendedConfigPath = append(extendedConfigPath, getExtendsConfigPath(fileName, host, newBase, errors, createCompilerDiagnostic));
}
}
else {
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", getCompilerOptionValueTypeString(extendsOptionDeclaration.element)));
}
@@ -3428,7 +3428,12 @@ function getExtendsConfigPath(
if (resolved.resolvedModule) {
return resolved.resolvedModule.resolvedFileName;
}
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
if (extendedConfig === "") {
errors.push(createDiagnostic(Diagnostics.Compiler_option_0_cannot_be_given_an_empty_string, "extends"));
}
else {
errors.push(createDiagnostic(Diagnostics.File_0_not_found, extendedConfig));
}
return undefined;
}