From 0cc3521b1065eaeb549b09c61cb210a9ec411c3a Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Wed, 1 Dec 2021 08:45:00 -0700 Subject: [PATCH] Describe defaults of more options (#46498) * Describe defaults of more options * Use enum members/values vs. strings * Update Baselines and/or Applied Lint Fixes Co-authored-by: TypeScript Bot --- src/compiler/commandLineParser.ts | 178 +++++++++--------- src/compiler/types.ts | 8 +- src/executeCommandLine/executeCommandLine.ts | 31 ++- src/harness/harnessIO.ts | 14 +- .../unittests/config/commandLineParsing.ts | 2 +- ...does-not-add-color-when-NO_COLOR-is-set.js | 12 +- ...-when-host-can't-provide-terminal-width.js | 12 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 12 +- 8 files changed, 156 insertions(+), 113 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b9d39151148a1..df9ee17f32d9f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,6 +1,10 @@ namespace ts { /* @internal */ - export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" }; + export const compileOnSaveCommandLineOption: CommandLineOption = { + name: "compileOnSave", + type: "boolean", + defaultValueDescription: false, + }; const jsxOptionMap = new Map(getEntries({ "preserve": JsxEmit.Preserve, @@ -117,6 +121,7 @@ namespace ts { })), category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Specify_how_the_TypeScript_watch_mode_works, + defaultValueDescription: WatchFileKind.UseFsEvents, }, { name: "watchDirectory", @@ -128,6 +133,7 @@ namespace ts { })), category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Specify_how_directories_are_watched_on_systems_that_lack_recursive_file_watching_functionality, + defaultValueDescription: WatchDirectoryKind.UseFsEvents, }, { name: "fallbackPolling", @@ -139,13 +145,14 @@ namespace ts { })), category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Specify_what_approach_the_watcher_should_use_if_the_system_runs_out_of_native_file_watchers, + defaultValueDescription: PollingWatchKind.PriorityInterval, }, { name: "synchronousWatchDirectory", type: "boolean", category: Diagnostics.Watch_and_Build_Modes, description: Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "excludeDirectories", @@ -182,13 +189,13 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Print_this_message, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "help", shortName: "?", type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "watch", @@ -198,7 +205,7 @@ namespace ts { isCommandLineOnly: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Watch_input_files, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "preserveWatchOutput", @@ -206,28 +213,28 @@ namespace ts { showInSimplifiedHelpView: false, category: Diagnostics.Output_Formatting, description: Diagnostics.Disable_wiping_the_console_in_watch_mode, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "listFiles", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Print_all_of_the_files_read_during_the_compilation, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "explainFiles", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "listEmittedFiles", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Print_the_names_of_emitted_files_after_a_compilation, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "pretty", @@ -235,28 +242,28 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Output_Formatting, description: Diagnostics.Enable_color_and_formatting_in_TypeScript_s_output_to_make_compiler_errors_easier_to_read, - defaultValueDescription: "true" + defaultValueDescription: true, }, { name: "traceResolution", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Log_paths_used_during_the_moduleResolution_process, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "diagnostics", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Output_compiler_performance_information_after_building, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "extendedDiagnostics", type: "boolean", category: Diagnostics.Compiler_Diagnostics, description: Diagnostics.Output_more_detailed_compiler_performance_information_after_building, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "generateCpuProfile", @@ -292,7 +299,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Watch_and_Build_Modes, 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, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "locale", @@ -329,7 +336,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Language_and_Environment, description: Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: "ES3" + defaultValueDescription: ScriptTarget.ES3, }; const commandOptionsWithoutBuild: CommandLineOption[] = [ @@ -340,7 +347,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Show_all_compiler_options, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "version", @@ -349,7 +356,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Print_the_compiler_s_version, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "init", @@ -357,7 +364,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "project", @@ -376,7 +383,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Command_line_Options, description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "showConfig", @@ -385,7 +392,7 @@ namespace ts { category: Diagnostics.Command_line_Options, isCommandLineOnly: true, description: Diagnostics.Print_the_final_configuration_instead_of_building, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "listFilesOnly", @@ -395,7 +402,7 @@ namespace ts { affectsEmit: true, isCommandLineOnly: true, description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing, - defaultValueDescription: "false", + defaultValueDescription: false, }, // Basic @@ -423,13 +430,15 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Modules, description: Diagnostics.Specify_what_module_code_is_generated, + defaultValueDescription: undefined, }, { name: "lib", type: "list", element: { name: "lib", - type: libMap + type: libMap, + defaultValueDescription: undefined, }, affectsProgramStructure: true, showInSimplifiedHelpView: true, @@ -444,7 +453,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.JavaScript_Support, description: Diagnostics.Allow_JavaScript_files_to_be_a_part_of_your_program_Use_the_checkJS_option_to_get_errors_from_these_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "checkJs", @@ -452,7 +461,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.JavaScript_Support, description: Diagnostics.Enable_error_reporting_in_type_checked_JavaScript_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "jsx", @@ -464,7 +473,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Language_and_Environment, description: Diagnostics.Specify_what_JSX_code_is_generated, - defaultValueDescription: "undefined" + defaultValueDescription: undefined, }, { name: "declaration", @@ -484,7 +493,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Emit, transpileOptionValue: undefined, - defaultValueDescription: "false", + defaultValueDescription: false, description: Diagnostics.Create_sourcemaps_for_d_ts_files }, { @@ -496,7 +505,7 @@ namespace ts { category: Diagnostics.Emit, description: Diagnostics.Only_output_d_ts_files_and_not_JavaScript_files, transpileOptionValue: undefined, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "sourceMap", @@ -504,7 +513,7 @@ namespace ts { affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Emit, - defaultValueDescription: "false", + defaultValueDescription: false, description: Diagnostics.Create_source_map_files_for_emitted_JavaScript_files, }, { @@ -545,7 +554,7 @@ namespace ts { isTSConfigOnly: true, category: Diagnostics.Projects, transpileOptionValue: undefined, - defaultValueDescription: "false", + defaultValueDescription: false, description: Diagnostics.Enable_constraints_that_allow_a_TypeScript_project_to_be_used_with_project_references, }, { @@ -565,7 +574,7 @@ namespace ts { affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Emit, - defaultValueDescription: "false", + defaultValueDescription: false, description: Diagnostics.Disable_emitting_comments, }, { @@ -575,7 +584,7 @@ namespace ts { category: Diagnostics.Emit, description: Diagnostics.Disable_emitting_files_from_a_compilation, transpileOptionValue: undefined, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "importHelpers", @@ -583,7 +592,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Allow_importing_helper_functions_from_tslib_once_per_project_instead_of_including_them_per_file, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "importsNotUsedAsValues", @@ -595,7 +604,8 @@ namespace ts { affectsEmit: true, affectsSemanticDiagnostics: true, category: Diagnostics.Emit, - description: Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types + description: Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, + defaultValueDescription: ImportsNotUsedAsValues.Remove, }, { name: "downlevelIteration", @@ -603,7 +613,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Emit_more_compliant_but_verbose_and_less_performant_JavaScript_for_iteration, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "isolatedModules", @@ -611,7 +621,7 @@ namespace ts { category: Diagnostics.Interop_Constraints, description: Diagnostics.Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports, transpileOptionValue: true, - defaultValueDescription: "false" + defaultValueDescription: false, }, // Strict Type Checks @@ -623,7 +633,7 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Type_Checking, description: Diagnostics.Enable_all_strict_type_checking_options, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noImplicitAny", @@ -684,7 +694,7 @@ namespace ts { strictFlag: true, category: Diagnostics.Type_Checking, description: Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "alwaysStrict", @@ -703,7 +713,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Enable_error_reporting_when_a_local_variables_aren_t_read, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noUnusedParameters", @@ -711,7 +721,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Raise_an_error_when_a_function_parameter_isn_t_read, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "exactOptionalPropertyTypes", @@ -719,7 +729,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "noImplicitReturns", @@ -727,7 +737,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Enable_error_reporting_for_codepaths_that_do_not_explicitly_return_in_a_function, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noFallthroughCasesInSwitch", @@ -736,7 +746,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "noUncheckedIndexedAccess", @@ -744,7 +754,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Include_undefined_in_index_signature_results, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "noImplicitOverride", @@ -752,7 +762,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "noPropertyAccessFromIndexSignature", @@ -760,7 +770,7 @@ namespace ts { showInSimplifiedHelpView: false, category: Diagnostics.Type_Checking, description: Diagnostics.Enforces_using_indexed_accessors_for_keys_declared_using_an_indexed_type, - defaultValueDescription: "false" + defaultValueDescription: false, }, // Module Resolution @@ -855,14 +865,14 @@ namespace ts { showInSimplifiedHelpView: true, category: Diagnostics.Interop_Constraints, description: Diagnostics.Emit_additional_JavaScript_to_ease_support_for_importing_CommonJS_modules_This_enables_allowSyntheticDefaultImports_for_type_compatibility, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "preserveSymlinks", type: "boolean", category: Diagnostics.Interop_Constraints, description: Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "allowUmdGlobalAccess", @@ -870,7 +880,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Modules, description: Diagnostics.Allow_accessing_UMD_globals_from_modules, - defaultValueDescription: "false" + defaultValueDescription: false, }, // Source Maps @@ -896,7 +906,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Include_sourcemap_files_inside_the_emitted_JavaScript, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "inlineSources", @@ -904,7 +914,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Include_source_code_in_the_sourcemaps_inside_the_emitted_JavaScript, - defaultValueDescription: "false" + defaultValueDescription: false, }, // Experimental @@ -914,7 +924,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Language_and_Environment, description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "emitDecoratorMetadata", @@ -923,7 +933,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Language_and_Environment, description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files, - defaultValueDescription: "false", + defaultValueDescription: false, }, // Advanced @@ -956,7 +966,7 @@ namespace ts { affectsModuleResolution: true, category: Diagnostics.Modules, description: Diagnostics.Enable_importing_json_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { @@ -983,7 +993,7 @@ namespace ts { type: "boolean", category: Diagnostics.Completeness, description: Diagnostics.Skip_type_checking_d_ts_files_that_are_included_with_TypeScript, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "charset", @@ -998,7 +1008,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "newLine", @@ -1018,7 +1028,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Output_Formatting, description: Diagnostics.Disable_truncating_types_in_error_messages, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noLib", @@ -1029,7 +1039,7 @@ namespace ts { // We are not returning a sourceFile for lib file when asked by the program, // so pass --noLib to avoid reporting a file not found error. transpileOptionValue: true, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noResolve", @@ -1040,7 +1050,7 @@ namespace ts { // We are not doing a full typecheck, we are not resolving the whole context, // so pass --noResolve to avoid reporting missing file errors. transpileOptionValue: true, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "stripInternal", @@ -1048,7 +1058,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "disableSizeLimit", @@ -1056,7 +1066,7 @@ namespace ts { affectsProgramStructure: true, category: Diagnostics.Editor_Support, description: Diagnostics.Remove_the_20mb_cap_on_total_source_code_size_for_JavaScript_files_in_the_TypeScript_language_server, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "disableSourceOfProjectReferenceRedirect", @@ -1064,7 +1074,7 @@ namespace ts { isTSConfigOnly: true, category: Diagnostics.Projects, description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "disableSolutionSearching", @@ -1072,7 +1082,7 @@ namespace ts { isTSConfigOnly: true, category: Diagnostics.Projects, description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "disableReferencedProjectLoad", @@ -1080,7 +1090,7 @@ namespace ts { isTSConfigOnly: true, category: Diagnostics.Projects, description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "noImplicitUseStrict", @@ -1088,7 +1098,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Disable_adding_use_strict_directives_in_emitted_JavaScript_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noEmitHelpers", @@ -1096,7 +1106,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Disable_generating_custom_helper_functions_like_extends_in_compiled_output, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "noEmitOnError", @@ -1105,7 +1115,7 @@ namespace ts { category: Diagnostics.Emit, transpileOptionValue: undefined, description: Diagnostics.Disable_emitting_files_if_any_type_checking_errors_are_reported, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "preserveConstEnums", @@ -1113,7 +1123,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code, - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "declarationDir", @@ -1130,7 +1140,7 @@ namespace ts { type: "boolean", category: Diagnostics.Completeness, description: Diagnostics.Skip_type_checking_all_d_ts_files, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "allowUnusedLabels", @@ -1139,7 +1149,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Disable_error_reporting_for_unused_labels, - defaultValueDescription: "undefined" + defaultValueDescription: undefined, }, { name: "allowUnreachableCode", @@ -1148,7 +1158,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Type_Checking, description: Diagnostics.Disable_error_reporting_for_unreachable_code, - defaultValueDescription: "undefined" + defaultValueDescription: undefined, }, { name: "suppressExcessPropertyErrors", @@ -1156,7 +1166,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Disable_reporting_of_excess_property_errors_during_the_creation_of_object_literals, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "suppressImplicitAnyIndexErrors", @@ -1164,7 +1174,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Suppress_noImplicitAny_errors_when_indexing_objects_that_lack_index_signatures, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "forceConsistentCasingInFileNames", @@ -1172,7 +1182,7 @@ namespace ts { affectsModuleResolution: true, category: Diagnostics.Interop_Constraints, description: Diagnostics.Ensure_that_casing_is_correct_in_imports, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "maxNodeModuleJsDepth", @@ -1180,7 +1190,7 @@ namespace ts { affectsModuleResolution: true, category: Diagnostics.JavaScript_Support, description: Diagnostics.Specify_the_maximum_folder_depth_used_for_checking_JavaScript_files_from_node_modules_Only_applicable_with_allowJs, - defaultValueDescription: "0" + defaultValueDescription: 0, }, { name: "noStrictGenericChecks", @@ -1188,7 +1198,7 @@ namespace ts { affectsSemanticDiagnostics: true, category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, - defaultValueDescription: "false" + defaultValueDescription: false, }, { name: "useDefineForClassFields", @@ -1205,7 +1215,7 @@ namespace ts { affectsEmit: true, category: Diagnostics.Emit, description: Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed, - defaultValueDescription: "false", + defaultValueDescription: false, }, { @@ -1213,7 +1223,7 @@ namespace ts { type: "boolean", category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Make_keyof_only_return_strings_instead_of_string_numbers_or_symbols_Legacy_option, - defaultValueDescription: "false" + defaultValueDescription: false, }, { // A list of plugins to load in the language service @@ -1269,7 +1279,7 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Enable_verbose_logging, type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "dry", @@ -1277,7 +1287,7 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "force", @@ -1285,14 +1295,14 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "clean", category: Diagnostics.Command_line_Options, description: Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, } ]; @@ -1310,12 +1320,12 @@ namespace ts { */ name: "enableAutoDiscovery", type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "enable", type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, { name: "include", @@ -1336,7 +1346,7 @@ namespace ts { { name: "disableFilenameBasedTypeAcquisition", type: "boolean", - defaultValueDescription: "false", + defaultValueDescription: false, }, ]; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b5424879454f6..bdff510977b41 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6335,7 +6335,7 @@ namespace ts { isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does. - defaultValueDescription?: string | DiagnosticMessage; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n. + defaultValueDescription?: string | number | boolean | DiagnosticMessage; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n. paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file isCommandLineOnly?: boolean; @@ -6355,23 +6355,25 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfStringType extends CommandLineOptionBase { type: "string"; + defaultValueDescription?: string | undefined | DiagnosticMessage; } /* @internal */ export interface CommandLineOptionOfNumberType extends CommandLineOptionBase { type: "number"; - defaultValueDescription: `${number | undefined}` | DiagnosticMessage; + defaultValueDescription: number | undefined | DiagnosticMessage; } /* @internal */ export interface CommandLineOptionOfBooleanType extends CommandLineOptionBase { type: "boolean"; - defaultValueDescription: `${boolean | undefined}` | DiagnosticMessage; + defaultValueDescription: boolean | undefined | DiagnosticMessage; } /* @internal */ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { type: ESMap; // an object literal mapping named values to actual values + defaultValueDescription: number | string | undefined | DiagnosticMessage; } /* @internal */ diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 54e15e1fb37b0..2c0d7ba64e7fd 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -160,7 +160,13 @@ namespace ts { // value type and possible value const valueCandidates = getValueCandidate(option); - const defaultValueDescription = typeof option.defaultValueDescription === "object" ? getDiagnosticText(option.defaultValueDescription) : option.defaultValueDescription; + const defaultValueDescription = + typeof option.defaultValueDescription === "object" + ? getDiagnosticText(option.defaultValueDescription) + : formatDefaultValue( + option.defaultValueDescription, + option.type === "list" ? option.element.type : option.type + ); const terminalWidth = sys.getWidthOfTerminal?.() ?? 0; // Note: child_process might return `terminalWidth` as undefined. @@ -203,6 +209,19 @@ namespace ts { } return text; + function formatDefaultValue( + defaultValue: CommandLineOption["defaultValueDescription"], + type: CommandLineOption["type"] + ) { + return defaultValue !== undefined && typeof type === "object" + // e.g. ScriptTarget.ES2015 -> "es6/es2015" + ? arrayFrom(type.entries()) + .filter(([, value]) => value === defaultValue) + .map(([name]) => name) + .join("/") + : String(defaultValue); + } + function showAdditionalInfoOutput(valueCandidates: ValueCandidate | undefined, option: CommandLineOption): boolean { const ignoreValues = ["string"]; const ignoredDescriptions = [undefined, "false", "n/a"]; @@ -286,8 +305,14 @@ namespace ts { break; default: // ESMap - const keys = arrayFrom(option.type.keys()); - possibleValues = keys.join(", "); + // Group synonyms: es6/es2015 + const inverted: { [value: string]: string[] } = {}; + option.type.forEach((value, name) => { + (inverted[value] ||= []).push(name); + }); + return getEntries(inverted) + .map(([, synonyms]) => synonyms.join("/")) + .join(", "); } return possibleValues; } diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index bf9f45d8826b4..50c14ea0f6f80 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -304,21 +304,21 @@ namespace Harness { // Additional options not already in ts.optionDeclarations const harnessOptionDeclarations: ts.CommandLineOption[] = [ - { name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: "false" }, - { name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: "false" }, + { name: "allowNonTsExtensions", type: "boolean", defaultValueDescription: false }, + { name: "useCaseSensitiveFileNames", type: "boolean", defaultValueDescription: false }, { name: "baselineFile", type: "string" }, { name: "includeBuiltFile", type: "string" }, { name: "fileName", type: "string" }, { name: "libFiles", type: "string" }, - { name: "noErrorTruncation", type: "boolean", defaultValueDescription: "false" }, - { name: "suppressOutputPathCheck", type: "boolean", defaultValueDescription: "false" }, - { name: "noImplicitReferences", type: "boolean", defaultValueDescription: "false" }, + { name: "noErrorTruncation", type: "boolean", defaultValueDescription: false }, + { name: "suppressOutputPathCheck", type: "boolean", defaultValueDescription: false }, + { name: "noImplicitReferences", type: "boolean", defaultValueDescription: false }, { name: "currentDirectory", type: "string" }, { name: "symlink", type: "string" }, { name: "link", type: "string" }, - { name: "noTypesAndSymbols", type: "boolean", defaultValueDescription: "false" }, + { name: "noTypesAndSymbols", type: "boolean", defaultValueDescription: false }, // Emitted js baseline will print full paths for every output file - { name: "fullEmitPaths", type: "boolean", defaultValueDescription: "false" } + { name: "fullEmitPaths", type: "boolean", defaultValueDescription: false }, ]; let optionsIndex: ts.ESMap; diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 34644a0976640..0c9a9fd954bf7 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -534,7 +534,7 @@ namespace ts { isTSConfigOnly: true, category: Diagnostics.Backwards_Compatibility, description: Diagnostics.Enable_project_compilation, - defaultValueDescription: "undefined", + defaultValueDescription: undefined, } ]; return { diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js index 01d07f61429b4..ab599544b7983 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/does-not-add-color-when-NO_COLOR-is-set.js @@ -68,16 +68,18 @@ default: true --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6, es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext -default: ES3 +one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, system, umd, es6, es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6, es2015, es7, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol, es2020.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise, es2021.string, es2021.weakref, es2021.intl, es2022.array, es2022.error, es2022.object, es2022.string, esnext.array, esnext.symbol, esnext.asynciterable, esnext.intl, esnext.bigint, esnext.string, esnext.promise, esnext.weakref +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +default: undefined --allowJs Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. @@ -91,7 +93,7 @@ default: false --jsx Specify what JSX code is generated. -one of: preserve, react-native, react, react-jsx, react-jsxdev +one of: preserve, react, react-native, react-jsx, react-jsxdev default: undefined --declaration, -d diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index 4db9e7df4d352..61b34a3054463 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -68,16 +68,18 @@ default: true --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6, es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext -default: ES3 +one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, system, umd, es6, es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6, es2015, es7, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol, es2020.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise, es2021.string, es2021.weakref, es2021.intl, es2022.array, es2022.error, es2022.object, es2022.string, esnext.array, esnext.symbol, esnext.asynciterable, esnext.intl, esnext.bigint, esnext.string, esnext.promise, esnext.weakref +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +default: undefined --allowJs Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. @@ -91,7 +93,7 @@ default: false --jsx Specify what JSX code is generated. -one of: preserve, react-native, react, react-jsx, react-jsxdev +one of: preserve, react, react-native, react-jsx, react-jsxdev default: undefined --declaration, -d diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 4db9e7df4d352..61b34a3054463 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -68,16 +68,18 @@ default: true --target, -t Set the JavaScript language version for emitted JavaScript and include compatible library declarations. -one of: es3, es5, es6, es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext -default: ES3 +one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext +default: es3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, system, umd, es6, es2015, es2020, es2022, esnext, node12, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node12, nodenext +default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6, es2015, es7, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol, es2020.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise, es2021.string, es2021.weakref, es2021.intl, es2022.array, es2022.error, es2022.object, es2022.string, esnext.array, esnext.symbol, esnext.asynciterable, esnext.intl, esnext.bigint, esnext.string, esnext.promise, esnext.weakref +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2020.bigint/esnext.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array/esnext.array, es2022.error, es2022.object, es2022.string/esnext.string, esnext.intl +default: undefined --allowJs Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. @@ -91,7 +93,7 @@ default: false --jsx Specify what JSX code is generated. -one of: preserve, react-native, react, react-jsx, react-jsxdev +one of: preserve, react, react-native, react-jsx, react-jsxdev default: undefined --declaration, -d