Skip to content

Commit 4981c56

Browse files
committed
Require defaultValueDescription of number/boolean options
1 parent 36bf6cb commit 4981c56

File tree

4 files changed

+65
-30
lines changed

4 files changed

+65
-30
lines changed

src/compiler/commandLineParser.ts

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ts {
22
/* @internal */
3-
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" };
3+
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" };
44

55
const jsxOptionMap = new Map(getEntries({
66
"preserve": JsxEmit.Preserve,
@@ -140,6 +140,7 @@ namespace ts {
140140
type: "boolean",
141141
category: Diagnostics.Watch_and_Build_Modes,
142142
description: Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
143+
defaultValueDescription: "false",
143144
},
144145
{
145146
name: "excludeDirectories",
@@ -176,11 +177,13 @@ namespace ts {
176177
showInSimplifiedHelpView: true,
177178
category: Diagnostics.Command_line_Options,
178179
description: Diagnostics.Print_this_message,
180+
defaultValueDescription: "false",
179181
},
180182
{
181183
name: "help",
182184
shortName: "?",
183-
type: "boolean"
185+
type: "boolean",
186+
defaultValueDescription: "false",
184187
},
185188
{
186189
name: "watch",
@@ -190,13 +193,15 @@ namespace ts {
190193
isCommandLineOnly: true,
191194
category: Diagnostics.Command_line_Options,
192195
description: Diagnostics.Watch_input_files,
196+
defaultValueDescription: "false",
193197
},
194198
{
195199
name: "preserveWatchOutput",
196200
type: "boolean",
197201
showInSimplifiedHelpView: false,
198202
category: Diagnostics.Output_Formatting,
199203
description: Diagnostics.Disable_wiping_the_console_in_watch_mode,
204+
defaultValueDescription: "false",
200205
},
201206
{
202207
name: "listFiles",
@@ -209,7 +214,8 @@ namespace ts {
209214
name: "explainFiles",
210215
type: "boolean",
211216
category: Diagnostics.Compiler_Diagnostics,
212-
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included
217+
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included,
218+
defaultValueDescription: "false",
213219
},
214220
{
215221
name: "listEmittedFiles",
@@ -280,7 +286,8 @@ namespace ts {
280286
affectsSemanticDiagnostics: true,
281287
affectsEmit: true,
282288
category: Diagnostics.Watch_and_Build_Modes,
283-
description: Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
289+
description: Diagnostics.Have_recompiles_in_projects_that_use_incremental_and_watch_mode_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it,
290+
defaultValueDescription: "false",
284291
},
285292
{
286293
name: "locale",
@@ -327,6 +334,7 @@ namespace ts {
327334
showInSimplifiedHelpView: true,
328335
category: Diagnostics.Command_line_Options,
329336
description: Diagnostics.Show_all_compiler_options,
337+
defaultValueDescription: "false",
330338
},
331339
{
332340
name: "version",
@@ -335,13 +343,15 @@ namespace ts {
335343
showInSimplifiedHelpView: true,
336344
category: Diagnostics.Command_line_Options,
337345
description: Diagnostics.Print_the_compiler_s_version,
346+
defaultValueDescription: "false",
338347
},
339348
{
340349
name: "init",
341350
type: "boolean",
342351
showInSimplifiedHelpView: true,
343352
category: Diagnostics.Command_line_Options,
344353
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
354+
defaultValueDescription: "false",
345355
},
346356
{
347357
name: "project",
@@ -359,15 +369,17 @@ namespace ts {
359369
shortName: "b",
360370
showInSimplifiedHelpView: true,
361371
category: Diagnostics.Command_line_Options,
362-
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
372+
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
373+
defaultValueDescription: "false",
363374
},
364375
{
365376
name: "showConfig",
366377
type: "boolean",
367378
showInSimplifiedHelpView: true,
368379
category: Diagnostics.Command_line_Options,
369380
isCommandLineOnly: true,
370-
description: Diagnostics.Print_the_final_configuration_instead_of_building
381+
description: Diagnostics.Print_the_final_configuration_instead_of_building,
382+
defaultValueDescription: "false",
371383
},
372384
{
373385
name: "listFilesOnly",
@@ -376,7 +388,8 @@ namespace ts {
376388
affectsSemanticDiagnostics: true,
377389
affectsEmit: true,
378390
isCommandLineOnly: true,
379-
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
391+
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
392+
defaultValueDescription: "false",
380393
},
381394

382395
// Basic
@@ -665,6 +678,7 @@ namespace ts {
665678
strictFlag: true,
666679
category: Diagnostics.Type_Checking,
667680
description: Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
681+
defaultValueDescription: "false",
668682
},
669683
{
670684
name: "alwaysStrict",
@@ -698,7 +712,8 @@ namespace ts {
698712
type: "boolean",
699713
affectsSemanticDiagnostics: true,
700714
category: Diagnostics.Type_Checking,
701-
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
715+
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
716+
defaultValueDescription: "false",
702717
},
703718
{
704719
name: "noImplicitReturns",
@@ -714,21 +729,24 @@ namespace ts {
714729
affectsBindDiagnostics: true,
715730
affectsSemanticDiagnostics: true,
716731
category: Diagnostics.Type_Checking,
717-
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements
732+
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
733+
defaultValueDescription: "false",
718734
},
719735
{
720736
name: "noUncheckedIndexedAccess",
721737
type: "boolean",
722738
affectsSemanticDiagnostics: true,
723739
category: Diagnostics.Type_Checking,
724-
description: Diagnostics.Include_undefined_in_index_signature_results
740+
description: Diagnostics.Include_undefined_in_index_signature_results,
741+
defaultValueDescription: "false",
725742
},
726743
{
727744
name: "noImplicitOverride",
728745
type: "boolean",
729746
affectsSemanticDiagnostics: true,
730747
category: Diagnostics.Type_Checking,
731-
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
748+
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
749+
defaultValueDescription: "false",
732750
},
733751
{
734752
name: "noPropertyAccessFromIndexSignature",
@@ -838,6 +856,7 @@ namespace ts {
838856
type: "boolean",
839857
category: Diagnostics.Interop_Constraints,
840858
description: Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node,
859+
defaultValueDescription: "false",
841860
},
842861
{
843862
name: "allowUmdGlobalAccess",
@@ -888,15 +907,17 @@ namespace ts {
888907
type: "boolean",
889908
affectsSemanticDiagnostics: true,
890909
category: Diagnostics.Language_and_Environment,
891-
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators
910+
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
911+
defaultValueDescription: "false",
892912
},
893913
{
894914
name: "emitDecoratorMetadata",
895915
type: "boolean",
896916
affectsSemanticDiagnostics: true,
897917
affectsEmit: true,
898918
category: Diagnostics.Language_and_Environment,
899-
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files
919+
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
920+
defaultValueDescription: "false",
900921
},
901922

902923
// Advanced
@@ -1021,6 +1042,7 @@ namespace ts {
10211042
affectsEmit: true,
10221043
category: Diagnostics.Emit,
10231044
description: Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
1045+
defaultValueDescription: "false",
10241046
},
10251047
{
10261048
name: "disableSizeLimit",
@@ -1035,21 +1057,24 @@ namespace ts {
10351057
type: "boolean",
10361058
isTSConfigOnly: true,
10371059
category: Diagnostics.Projects,
1038-
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects
1060+
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects,
1061+
defaultValueDescription: "false",
10391062
},
10401063
{
10411064
name: "disableSolutionSearching",
10421065
type: "boolean",
10431066
isTSConfigOnly: true,
10441067
category: Diagnostics.Projects,
1045-
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing
1068+
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing,
1069+
defaultValueDescription: "false",
10461070
},
10471071
{
10481072
name: "disableReferencedProjectLoad",
10491073
type: "boolean",
10501074
isTSConfigOnly: true,
10511075
category: Diagnostics.Projects,
1052-
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript
1076+
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript,
1077+
defaultValueDescription: "false",
10531078
},
10541079
{
10551080
name: "noImplicitUseStrict",
@@ -1082,6 +1107,7 @@ namespace ts {
10821107
affectsEmit: true,
10831108
category: Diagnostics.Emit,
10841109
description: Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
1110+
defaultValueDescription: "false",
10851111
},
10861112
{
10871113
name: "declarationDir",
@@ -1173,6 +1199,7 @@ namespace ts {
11731199
affectsEmit: true,
11741200
category: Diagnostics.Emit,
11751201
description: Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed,
1202+
defaultValueDescription: "false",
11761203
},
11771204

11781205
{
@@ -1235,27 +1262,31 @@ namespace ts {
12351262
shortName: "v",
12361263
category: Diagnostics.Command_line_Options,
12371264
description: Diagnostics.Enable_verbose_logging,
1238-
type: "boolean"
1265+
type: "boolean",
1266+
defaultValueDescription: "false",
12391267
},
12401268
{
12411269
name: "dry",
12421270
shortName: "d",
12431271
category: Diagnostics.Command_line_Options,
12441272
description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
1245-
type: "boolean"
1273+
type: "boolean",
1274+
defaultValueDescription: "false",
12461275
},
12471276
{
12481277
name: "force",
12491278
shortName: "f",
12501279
category: Diagnostics.Command_line_Options,
12511280
description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
1252-
type: "boolean"
1281+
type: "boolean",
1282+
defaultValueDescription: "false",
12531283
},
12541284
{
12551285
name: "clean",
12561286
category: Diagnostics.Command_line_Options,
12571287
description: Diagnostics.Delete_the_outputs_of_all_projects,
1258-
type: "boolean"
1288+
type: "boolean",
1289+
defaultValueDescription: "false",
12591290
}
12601291
];
12611292

@@ -1273,10 +1304,12 @@ namespace ts {
12731304
*/
12741305
name: "enableAutoDiscovery",
12751306
type: "boolean",
1307+
defaultValueDescription: "false",
12761308
},
12771309
{
12781310
name: "enable",
12791311
type: "boolean",
1312+
defaultValueDescription: "false",
12801313
},
12811314
{
12821315
name: "include",
@@ -1297,6 +1330,7 @@ namespace ts {
12971330
{
12981331
name: "disableFilenameBasedTypeAcquisition",
12991332
type: "boolean",
1333+
defaultValueDescription: "false",
13001334
},
13011335
];
13021336

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6345,13 +6345,13 @@ namespace ts {
63456345
/* @internal */
63466346
export interface CommandLineOptionOfNumberType extends CommandLineOptionBase {
63476347
type: "number";
6348-
defaultValueDescription?: `${number | undefined}` | DiagnosticMessage;
6348+
defaultValueDescription: `${number | undefined}` | DiagnosticMessage;
63496349
}
63506350

63516351
/* @internal */
63526352
export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase {
63536353
type: "boolean";
6354-
defaultValueDescription?: `${boolean | undefined}` | DiagnosticMessage;
6354+
defaultValueDescription: `${boolean | undefined}` | DiagnosticMessage;
63556355
}
63566356

63576357
/* @internal */

src/harness/harnessIO.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,21 @@ namespace Harness {
303303

304304
// Additional options not already in ts.optionDeclarations
305305
const harnessOptionDeclarations: ts.CommandLineOption[] = [
306-
{ name: "allowNonTsExtensions", type: "boolean" },
307-
{ name: "useCaseSensitiveFileNames", type: "boolean" },
306+
{ name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: "false" },
307+
{ name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: "false" },
308308
{ name: "baselineFile", type: "string" },
309309
{ name: "includeBuiltFile", type: "string" },
310310
{ name: "fileName", type: "string" },
311311
{ name: "libFiles", type: "string" },
312-
{ name: "noErrorTruncation", type: "boolean" },
313-
{ name: "suppressOutputPathCheck", type: "boolean" },
314-
{ name: "noImplicitReferences", type: "boolean" },
312+
{ name: "noErrorTruncation", type: "boolean", defaultValueDescription: "false" },
313+
{ name: "suppressOutputPathCheck", type: "boolean", defaultValueDescription: "false" },
314+
{ name: "noImplicitReferences", type: "boolean", defaultValueDescription: "false" },
315315
{ name: "currentDirectory", type: "string" },
316316
{ name: "symlink", type: "string" },
317317
{ name: "link", type: "string" },
318-
{ name: "noTypesAndSymbols", type: "boolean" },
318+
{ name: "noTypesAndSymbols", type: "boolean", defaultValueDescription: "false" },
319319
// Emitted js baseline will print full paths for every output file
320-
{ name: "fullEmitPaths", type: "boolean" }
320+
{ name: "fullEmitPaths", type: "boolean", defaultValueDescription: "false" }
321321
];
322322

323323
let optionsIndex: ts.ESMap<string, ts.CommandLineOption>;

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,15 @@ namespace ts {
526526
nonNullValue,
527527
diagnosticMessage: Diagnostics.Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line,
528528
workerDiagnostic: () => {
529-
const optionDeclarations = [
529+
const optionDeclarations: CommandLineOption[] = [
530530
...compilerOptionsDidYouMeanDiagnostics.optionDeclarations,
531531
{
532532
name: "optionName",
533533
type: type(),
534534
isTSConfigOnly: true,
535535
category: Diagnostics.Backwards_Compatibility,
536536
description: Diagnostics.Enable_project_compilation,
537+
defaultValueDescription: "undefined",
537538
}
538539
];
539540
return {

0 commit comments

Comments
 (0)