mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 02:41:30 -05:00
Add support for raising if you set a tsconfig entry of target/module with the right setting in the root (#44964)
* Add support for raising if you set a tsconfig entry of target/module with the right setting in the root * Switch to check for any compiler option in the root which doesn't include compilerOptions * Get green * Apply suggestions from code review Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com> * Update src/compiler/commandLineParser.ts Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com> Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
@@ -2852,6 +2852,7 @@ namespace ts {
|
||||
let typeAcquisition: TypeAcquisition | undefined, typingOptionstypeAcquisition: TypeAcquisition | undefined;
|
||||
let watchOptions: WatchOptions | undefined;
|
||||
let extendedConfigPath: string | undefined;
|
||||
let rootCompilerOptions: PropertyName[] | undefined;
|
||||
|
||||
const optionsIterator: JsonConversionNotifier = {
|
||||
onSetValidOptionKeyValueInParent(parentOption: string, option: CommandLineOption, value: CompilerOptionsValue) {
|
||||
@@ -2894,6 +2895,9 @@ namespace ts {
|
||||
if (key === "excludes") {
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, keyNode, Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
|
||||
}
|
||||
if (find(commandOptionsWithoutBuild, (opt) => opt.name === key)) {
|
||||
rootCompilerOptions = append(rootCompilerOptions, keyNode);
|
||||
}
|
||||
}
|
||||
};
|
||||
const json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator);
|
||||
@@ -2913,6 +2917,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (rootCompilerOptions && json && json.compilerOptions === undefined) {
|
||||
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, rootCompilerOptions[0], Diagnostics._0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file, getTextOfPropertyName(rootCompilerOptions[0]) as string));
|
||||
}
|
||||
|
||||
return { raw: json, options, watchOptions, typeAcquisition, extendedConfigPath };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user