Fix tsconfig module parsing
This commit is contained in:
Родитель
ba051344c1
Коммит
5a4499a939
|
@ -3372,7 +3372,12 @@ function parseOwnConfigOfJsonSourceFile(
|
|||
else if (parentOption === typeAcquisitionDeclaration) currentOption = typeAcquisition ??= getDefaultTypeAcquisition(configFileName);
|
||||
else if (parentOption === moduleOptionDeclaration) currentOption = moduleOption ??= {};
|
||||
else Debug.fail("Unknown option");
|
||||
currentOption[option.name] = value;
|
||||
if (currentOption === options && option.name === "module" && moduleOption) {
|
||||
options.module = moduleOption;
|
||||
}
|
||||
else {
|
||||
currentOption[option.name] = value;
|
||||
}
|
||||
}
|
||||
else if (keyText && parentOption?.extraKeyDiagnostics) {
|
||||
if (parentOption.elementOptions) {
|
||||
|
@ -3592,18 +3597,8 @@ export function convertJsonOption(
|
|||
return isNullOrUndefined(validatedValue) ? validatedValue : normalizeNonListOptionValue(opt, basePath, validatedValue);
|
||||
}
|
||||
else {
|
||||
// const result: NestedCompilerOption = {};
|
||||
// for (const id in value as NestedCompilerOption) {
|
||||
// const property = (value as NestedCompilerOption)[id];
|
||||
// const subOption = opt.elementOptions.get(id);
|
||||
// if (subOption) {
|
||||
// result[opt.name] = convertJsonOption(opt, property, basePath, errors, propertyAssignment, valueExpression, sourceFile);
|
||||
// }
|
||||
// else {
|
||||
// errors.push(createUnknownOptionError(id, opt.extraKeyDiagnostics, /*unknownOptionErrorText*/ undefined, propertyAssignment?.name, sourceFile));
|
||||
// }
|
||||
// }
|
||||
return {};
|
||||
// Property keys have already been converted/validated
|
||||
return value;
|
||||
}
|
||||
}
|
||||
else if (!isString(opt.type)) {
|
||||
|
|
|
@ -307,4 +307,17 @@ describe("unittests:: config:: convertCompilerOptionsFromJson", () => {
|
|||
baselineCompilerOptionsJsonText("Don't crash when root expression is not object at all", `42`, "tsconfig.json");
|
||||
|
||||
baselineCompilerOptionsJsonText("Allow trailing comments", `{} // no options`, "tsconfig.json");
|
||||
|
||||
baselineCompilerOptionsJsonText(
|
||||
"module as object",
|
||||
`{
|
||||
"compilerOptions": {
|
||||
"module": {
|
||||
"preset": "nodenext",
|
||||
"formatDetection": "defaultmodule"
|
||||
}
|
||||
}
|
||||
}`,
|
||||
"tsconfig.json",
|
||||
);
|
||||
});
|
||||
|
|
|
@ -144,6 +144,15 @@ describe("unittests:: config:: tsconfigParsing:: parseConfigFileTextToJson", ()
|
|||
}`,
|
||||
]);
|
||||
|
||||
baselineParseResult("module as object", () => [`{
|
||||
"compilerOptions": {
|
||||
"module": {
|
||||
"preset": "nodenext",
|
||||
"formatDetection": "defaultmodule",
|
||||
},
|
||||
},
|
||||
}`]);
|
||||
|
||||
baselinedParsed("returns error when tsconfig have excludes", () => [{
|
||||
jsonText: `{
|
||||
"compilerOptions": {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
Fs::
|
||||
//// [/apath/a.ts]
|
||||
|
||||
|
||||
//// [/apath/b.js]
|
||||
|
||||
|
||||
//// [/apath/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": {
|
||||
"preset": "nodenext",
|
||||
"formatDetection": "defaultmodule"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configFileName:: tsconfig.json
|
||||
CompilerOptions::
|
||||
{
|
||||
"module": {
|
||||
"preset": 199,
|
||||
"formatDetection": 2
|
||||
},
|
||||
"configFilePath": "tsconfig.json"
|
||||
}
|
||||
Errors::
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Input::
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": {
|
||||
"preset": "nodenext",
|
||||
"formatDetection": "defaultmodule",
|
||||
},
|
||||
},
|
||||
}
|
||||
Config::
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": {
|
||||
"preset": "nodenext",
|
||||
"formatDetection": "defaultmodule"
|
||||
}
|
||||
}
|
||||
}
|
||||
Errors::
|
||||
|
Загрузка…
Ссылка в новой задаче