Add flags on commandLineOption to indicate strictFlag or option affecting semanticDiagnostics

This commit is contained in:
Sheetal Nandi 2018-08-06 14:54:57 -07:00
parent d419968c0d
commit 4475d81b9c
3 changed files with 22 additions and 33 deletions

View file

@ -319,13 +319,15 @@ namespace ts {
{
name: "noImplicitAny",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
},
{
name: "strictNullChecks",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_strict_null_checks
@ -333,6 +335,7 @@ namespace ts {
{
name: "strictFunctionTypes",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_strict_checking_of_function_types
@ -340,6 +343,7 @@ namespace ts {
{
name: "strictPropertyInitialization",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
@ -347,6 +351,7 @@ namespace ts {
{
name: "noImplicitThis",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
@ -354,6 +359,7 @@ namespace ts {
{
name: "alwaysStrict",
type: "boolean",
strictFlag: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Strict_Type_Checking_Options,
description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
@ -363,6 +369,7 @@ namespace ts {
{
name: "noUnusedLocals",
type: "boolean",
affectsSemanticDiagnostics: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Additional_Checks,
description: Diagnostics.Report_errors_on_unused_locals,
@ -370,6 +377,7 @@ namespace ts {
{
name: "noUnusedParameters",
type: "boolean",
affectsSemanticDiagnostics: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Additional_Checks,
description: Diagnostics.Report_errors_on_unused_parameters,
@ -377,6 +385,7 @@ namespace ts {
{
name: "noImplicitReturns",
type: "boolean",
affectsSemanticDiagnostics: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Additional_Checks,
description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
@ -384,6 +393,7 @@ namespace ts {
{
name: "noFallthroughCasesInSwitch",
type: "boolean",
affectsSemanticDiagnostics: true,
showInSimplifiedHelpView: true,
category: Diagnostics.Additional_Checks,
description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
@ -640,6 +650,7 @@ namespace ts {
{
name: "noImplicitUseStrict",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
},
@ -678,24 +689,28 @@ namespace ts {
{
name: "allowUnusedLabels",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_report_errors_on_unused_labels
},
{
name: "allowUnreachableCode",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Do_not_report_errors_on_unreachable_code
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Suppress_excess_property_checks_for_object_literals,
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
},
@ -714,6 +729,7 @@ namespace ts {
{
name: "noStrictGenericChecks",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
},

View file

@ -4540,6 +4540,8 @@ namespace ts {
isCommandLineOnly?: boolean;
showInSimplifiedHelpView?: boolean;
category?: DiagnosticMessage;
strictFlag?: true; // true if the option is one of the flag under strict
affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics
}
/* @internal */

View file

@ -6972,38 +6972,9 @@ namespace ts {
return false;
}
return changedCompileOptionValueOf(newOptions, oldOptions, [
"noImplicitReturns",
"strict",
"suppressExcessPropertyErrors",
"suppressImplicitAnyIndexErrors",
"noFallthroughCasesInSwitch",
"noStrictGenericChecks",
"noUnusedLocals",
"noUnusedParameters",
"noImplicitUseStrict"
]) || changedStrictOptionValueOf(newOptions, oldOptions, [
"noImplicitAny",
"noImplicitThis",
"strictNullChecks",
"strictFunctionTypes",
"strictPropertyInitialization",
"alwaysStrict"
]);
}
function changedStrictOptionValueOf(newOptions: CompilerOptions, oldOptions: CompilerOptions, flags: StrictOptionName[]) {
for (const flag of flags) {
if (getStrictOptionValue(newOptions, flag) !== getStrictOptionValue(oldOptions, flag)) {
return true;
}
}
return false;
}
function changedCompileOptionValueOf(newOptions: CompilerOptions, oldOptions: CompilerOptions, optionKeys: (keyof CompilerOptions)[]) {
for (const optionKey of optionKeys) {
if (newOptions[optionKey] !== oldOptions[optionKey]) {
for (const option of optionDeclarations) {
if ((option.strictFlag && getStrictOptionValue(newOptions, option.name as StrictOptionName) !== getStrictOptionValue(oldOptions, option.name as StrictOptionName)) ||
(option.affectsSemanticDiagnostics && !newOptions[option.name] !== !oldOptions[option.name])) {
return true;
}
}