Skip to content

Create a new pull request #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22329,12 +22329,11 @@ namespace ts {
if (signature) {
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
if (inference.contraCandidates) {
const inferredContravariantType = getContravariantInference(inference);
// If we have both co- and contra-variant inferences, we prefer the contra-variant inference
// unless the co-variant inference is a subtype and not 'never'.
// unless the co-variant inference is a subtype of some contra-variant inference and not 'never'.
inferredType = inferredCovariantType && !(inferredCovariantType.flags & TypeFlags.Never) &&
isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
inferredCovariantType : inferredContravariantType;
some(inference.contraCandidates, t => isTypeSubtypeOf(inferredCovariantType, t)) ?
inferredCovariantType : getContravariantInference(inference);
}
else if (inferredCovariantType) {
inferredType = inferredCovariantType;
Expand Down
83 changes: 55 additions & 28 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace ts {
/* @internal */
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" };
export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" };

const jsxOptionMap = new Map(getEntries({
"preserve": JsxEmit.Preserve,
Expand Down Expand Up @@ -140,6 +140,7 @@ namespace ts {
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",
},
{
name: "excludeDirectories",
Expand Down Expand Up @@ -176,11 +177,13 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Print_this_message,
defaultValueDescription: "false",
},
{
name: "help",
shortName: "?",
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "watch",
Expand All @@ -190,14 +193,15 @@ namespace ts {
isCommandLineOnly: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Watch_input_files,
defaultValueDescription: "false",
},
{
name: "preserveWatchOutput",
type: "boolean",
showInSimplifiedHelpView: false,
category: Diagnostics.Output_Formatting,
description: Diagnostics.Disable_wiping_the_console_in_watch_mode,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "listFiles",
Expand All @@ -210,7 +214,8 @@ namespace ts {
name: "explainFiles",
type: "boolean",
category: Diagnostics.Compiler_Diagnostics,
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included
description: Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included,
defaultValueDescription: "false",
},
{
name: "listEmittedFiles",
Expand Down Expand Up @@ -281,7 +286,8 @@ namespace ts {
affectsSemanticDiagnostics: true,
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
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",
},
{
name: "locale",
Expand Down Expand Up @@ -328,6 +334,7 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Show_all_compiler_options,
defaultValueDescription: "false",
},
{
name: "version",
Expand All @@ -336,13 +343,15 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Print_the_compiler_s_version,
defaultValueDescription: "false",
},
{
name: "init",
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
defaultValueDescription: "false",
},
{
name: "project",
Expand All @@ -360,15 +369,17 @@ namespace ts {
shortName: "b",
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
description: Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date,
defaultValueDescription: "false",
},
{
name: "showConfig",
type: "boolean",
showInSimplifiedHelpView: true,
category: Diagnostics.Command_line_Options,
isCommandLineOnly: true,
description: Diagnostics.Print_the_final_configuration_instead_of_building
description: Diagnostics.Print_the_final_configuration_instead_of_building,
defaultValueDescription: "false",
},
{
name: "listFilesOnly",
Expand All @@ -377,7 +388,8 @@ namespace ts {
affectsSemanticDiagnostics: true,
affectsEmit: true,
isCommandLineOnly: true,
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
defaultValueDescription: "false",
},

// Basic
Expand Down Expand Up @@ -499,7 +511,6 @@ namespace ts {
category: Diagnostics.Emit,
description: Diagnostics.Specify_a_file_that_bundles_all_outputs_into_one_JavaScript_file_If_declaration_is_true_also_designates_a_file_that_bundles_all_d_ts_output,
transpileOptionValue: undefined,
defaultValueDescription: "n/a"
},
{
name: "outDir",
Expand All @@ -510,7 +521,6 @@ namespace ts {
showInSimplifiedHelpView: true,
category: Diagnostics.Emit,
description: Diagnostics.Specify_an_output_folder_for_all_emitted_files,
defaultValueDescription: "n/a"
},
{
name: "rootDir",
Expand Down Expand Up @@ -668,6 +678,7 @@ namespace ts {
strictFlag: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any,
defaultValueDescription: "false",
},
{
name: "alwaysStrict",
Expand Down Expand Up @@ -701,7 +712,8 @@ namespace ts {
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined
description: Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined,
defaultValueDescription: "false",
},
{
name: "noImplicitReturns",
Expand All @@ -717,21 +729,24 @@ namespace ts {
affectsBindDiagnostics: true,
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements
description: Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements,
defaultValueDescription: "false",
},
{
name: "noUncheckedIndexedAccess",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Include_undefined_in_index_signature_results
description: Diagnostics.Include_undefined_in_index_signature_results,
defaultValueDescription: "false",
},
{
name: "noImplicitOverride",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Type_Checking,
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier
description: Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier,
defaultValueDescription: "false",
},
{
name: "noPropertyAccessFromIndexSignature",
Expand Down Expand Up @@ -841,7 +856,7 @@ namespace ts {
type: "boolean",
category: Diagnostics.Interop_Constraints,
description: Diagnostics.Disable_resolving_symlinks_to_their_realpath_This_correlates_to_the_same_flag_in_node,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "allowUmdGlobalAccess",
Expand Down Expand Up @@ -892,15 +907,17 @@ namespace ts {
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators
description: Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators,
defaultValueDescription: "false",
},
{
name: "emitDecoratorMetadata",
type: "boolean",
affectsSemanticDiagnostics: true,
affectsEmit: true,
category: Diagnostics.Language_and_Environment,
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files
description: Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files,
defaultValueDescription: "false",
},

// Advanced
Expand Down Expand Up @@ -945,7 +962,6 @@ namespace ts {
category: Diagnostics.Backwards_Compatibility,
paramType: Diagnostics.FILE,
transpileOptionValue: undefined,
defaultValueDescription: "n/a",
description: Diagnostics.Deprecated_setting_Use_outFile_instead,
},
{
Expand Down Expand Up @@ -1026,6 +1042,7 @@ namespace ts {
affectsEmit: true,
category: Diagnostics.Emit,
description: Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments,
defaultValueDescription: "false",
},
{
name: "disableSizeLimit",
Expand All @@ -1040,21 +1057,24 @@ namespace ts {
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects
description: Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects,
defaultValueDescription: "false",
},
{
name: "disableSolutionSearching",
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing
description: Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing,
defaultValueDescription: "false",
},
{
name: "disableReferencedProjectLoad",
type: "boolean",
isTSConfigOnly: true,
category: Diagnostics.Projects,
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript
description: Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript,
defaultValueDescription: "false",
},
{
name: "noImplicitUseStrict",
Expand Down Expand Up @@ -1087,7 +1107,7 @@ namespace ts {
affectsEmit: true,
category: Diagnostics.Emit,
description: Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code,
defaultValueDescription: "n/a"
defaultValueDescription: "false",
},
{
name: "declarationDir",
Expand All @@ -1098,7 +1118,6 @@ namespace ts {
category: Diagnostics.Emit,
transpileOptionValue: undefined,
description: Diagnostics.Specify_the_output_directory_for_generated_declaration_files,
defaultValueDescription: "n/a"
},
{
name: "skipLibCheck",
Expand Down Expand Up @@ -1180,6 +1199,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",
},

{
Expand Down Expand Up @@ -1242,27 +1262,31 @@ namespace ts {
shortName: "v",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Enable_verbose_logging,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "dry",
shortName: "d",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "force",
shortName: "f",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
},
{
name: "clean",
category: Diagnostics.Command_line_Options,
description: Diagnostics.Delete_the_outputs_of_all_projects,
type: "boolean"
type: "boolean",
defaultValueDescription: "false",
}
];

Expand All @@ -1280,10 +1304,12 @@ namespace ts {
*/
name: "enableAutoDiscovery",
type: "boolean",
defaultValueDescription: "false",
},
{
name: "enable",
type: "boolean",
defaultValueDescription: "false",
},
{
name: "include",
Expand All @@ -1304,6 +1330,7 @@ namespace ts {
{
name: "disableFilenameBasedTypeAcquisition",
type: "boolean",
defaultValueDescription: "false",
},
];

Expand Down Expand Up @@ -2285,7 +2312,7 @@ namespace ts {
return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
}
else {
return (optionDefinition as CommandLineOptionOfCustomType).type;
return optionDefinition.type;
}
}

Expand Down
Loading