diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index d3903992ceda2..65e7b7f95d69b 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -345,7 +345,7 @@ "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020": "Zkompilujte projekt podle cesty k jeho konfiguračnímu souboru nebo do složky se souborem tsconfig.json.", "Compiler_option_0_expects_an_argument_6044": "Parametr kompilátoru {0} očekává argument.", "Compiler_option_0_requires_a_value_of_type_1_5024": "Parametr kompilátoru {0} vyžaduje hodnotu typu {1}.", - "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Kompilátor si rezervuje název {0} při generování nižší úrovně privátního identifikátoru.", + "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Kompilátor si rezervuje název {0} při generování privátního identifikátoru pro nižší úroveň.", "Composite_projects_may_not_disable_declaration_emit_6304": "Složené projekty nemůžou zakázat generování deklarací.", "Composite_projects_may_not_disable_incremental_compilation_6379": "Složené projekty nemůžou zakázat přírůstkovou kompilaci.", "Computed_property_names_are_not_allowed_in_enums_1164": "Názvy počítaných vlastností se ve výčtech nepovolují.", @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Nepovedlo se přeložit cestu {0} s příponami {1}.", "Could_not_write_file_0_Colon_1_5033": "Nedá se zapisovat do souboru {0}: {1}", "DIRECTORY_6038": "ADRESÁŘ", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "Deklarace rozšiřuje deklaraci v jiném souboru. Toto není možné serializovat.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Generování deklarací pro tento soubor vyžaduje, aby se použil privátní název {0}. Explicitní anotace typu může generování deklarací odblokovat.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Generování deklarací pro tento soubor vyžaduje, aby se použil privátní název {0} z modulu {1}. Explicitní anotace typu může generování deklarací odblokovat.", "Declaration_expected_1146": "Očekává se deklarace.", @@ -509,6 +510,7 @@ "Experimental_Options_6177": "Experimentální možnosti", "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219": "Experimentální podpora dekorátorů je funkce, která se v budoucí verzi může změnit. Toto upozornění odstraníte nastavením možnosti experimentalDecorators v tsconfig nebo jsconfig.", "Explicitly_specified_module_resolution_kind_Colon_0_6087": "Explicitně zadaný druh překladu modulu: {0}.", + "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791": "Pokud možnost target není nastavená na es2016 nebo novější, nedají se hodnoty bigint umocnit.", "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203": "Přiřazení exportu nelze použít, pokud jsou cílem moduly ECMAScript. Zkuste místo toho použít export default nebo jiný formát modulu.", "Export_assignment_is_not_supported_when_module_flag_is_system_1218": "Když má příznak --module hodnotu system, nepodporuje se přiřazení exportu.", "Export_declaration_conflicts_with_exported_declaration_of_0_2484": "Konflikty deklarace exportu s exportovanou deklarací {0}", @@ -558,6 +560,7 @@ "Fix_all_detected_spelling_errors_95026": "Opravit všechny zjištěné pravopisné chyby", "Fix_all_expressions_possibly_missing_await_95085": "Opravit všechny výrazy, kde je možné, že chybí await", "Fix_all_implicit_this_errors_95107": "Opravit všechny chyby implicit-'this'", + "Fix_all_incorrect_return_type_of_an_async_functions_90037": "Opravit všechny nesprávné návratové typy asynchronních funkcí", "Found_0_errors_6217": "Našel se tento počet chyb: {0}.", "Found_0_errors_Watching_for_file_changes_6194": "Byl nalezen tento počet chyb: {0}. Sledují se změny souborů.", "Found_1_error_6216": "Našla se 1 chyba.", @@ -611,7 +614,7 @@ "Import_declaration_0_is_using_private_name_1_4000": "Deklarace importu {0} používá privátní název {1}.", "Import_declaration_conflicts_with_local_declaration_of_0_2440": "Deklarace importu je v konfliktu s místní deklarací {0}.", "Import_declarations_in_a_namespace_cannot_reference_a_module_1147": "Deklarace importu v oboru názvů nemůžou odkazovat na modul.", - "Import_default_0_from_module_1_90032": "Importovat výchozí {0} z modulu {1}", + "Import_default_0_from_module_1_90032": "Importovat výchozí hodnotu {0} z modulu {1}", "Import_emit_helpers_from_tslib_6139": "Importovat pomocné rutiny pro generování z tslib", "Import_may_be_converted_to_a_default_import_80003": "Import se může převést na výchozí import.", "Import_name_cannot_be_0_2438": "Název importu nemůže být {0}.", @@ -631,7 +634,6 @@ "Initialize_property_0_in_the_constructor_90020": "Inicializovat vlastnost {0} v konstruktoru", "Initialize_static_property_0_90021": "Inicializovat statickou vlastnost {0}", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "Inicializátor instance členské proměnné {0} nemůže odkazovat na identifikátor {1} deklarovaný v konstruktoru.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Inicializátor parametru {0} nemůže odkazovat na identifikátor {1} deklarovaný po něm.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "Inicializátor tomuto elementu vazby neposkytuje žádnou hodnotu. Element vazby nemá žádnou výchozí hodnotu.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Inicializátory nejsou povolené v ambientních kontextech.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Inicializuje projekt TypeScript a vytvoří soubor tsconfig.json.", @@ -808,7 +810,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Signatury přetížení musí být všechny exportované nebo neexportované.", "Overload_signatures_must_all_be_optional_or_required_2386": "Signatury přetížení musí být všechny nepovinné nebo povinné.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Signatury přetížení musí být všechny veřejné, privátní nebo chráněné.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "Parametr {0} se nedá odkazovat v jeho vlastním inicializátoru.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Parametr {0} nemůže odkazovat na identifikátor {1} deklarovaný za ním.", + "Parameter_0_cannot_reference_itself_2372": "Parametr {0} nemůže odkazovat sám na sebe.", "Parameter_0_implicitly_has_an_1_type_7006": "Parametr {0} má implicitně typ {1}.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Parametr {0} má implicitně typ {1}, ale je možné, že lepší typ by se vyvodil z použití.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Parametr {0} není na stejné pozici jako parametr {1}.", @@ -946,6 +949,7 @@ "Remove_unused_declaration_for_Colon_0_90004": "Odebrat nepoužívané deklarace pro {0}", "Remove_unused_label_95053": "Odebrat nepoužitý popisek", "Remove_variable_statement_90010": "Odebrat příkaz proměnné", + "Replace_0_with_Promise_1_90036": "Místo {0} použijte Promise<{1}>", "Replace_all_unused_infer_with_unknown_90031": "Nahradit všechny nepoužívané příkazy infer za unknown", "Replace_import_with_0_95015": "Nahradí import použitím: {0}.", "Replace_infer_0_with_unknown_90030": "Nahradit infer {0} za unknown", @@ -1108,6 +1112,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "Operandem operátoru delete nemůže být privátní identifikátor.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "Operandem operátoru delete nemůže být vlastnost určená jen pro čtení.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "Operandem operátoru delete musí být odkaz na vlastnost.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "Operand operátoru delete musí být nepovinný.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "Operandem operátoru inkrementace nebo dekrementace nemůže být přístup k nepovinné vlastnosti.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "Operand operátoru inkrementace nebo dekrementace musí být proměnná nebo přístup k vlastnosti.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "Parser očekával, že najde token }, který by odpovídal zdejšímu tokenu {.", @@ -1116,12 +1121,12 @@ "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237": "Návratový typ funkce dekorátoru parametru funkce musí být void nebo any.", "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236": "Návratový typ funkce dekorátoru vlastnosti musí být void nebo any.", "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058": "Návratový typ asynchronní funkce musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.", - "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064": "Návratový typ asynchronní funkce nebo metody musí být globální typ Promise.", + "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064": "Návratový typ asynchronní funkce nebo metody musí být globální typ Promise. Zamýšleli jste napsat Promise<{0}>?", "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407": "Pravá strana příkazu for...in musí být typu any, typem objektu nebo parametrem typu, ale tady má typ {0}.", "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363": "Pravá strana aritmetické operace musí mít typ any, number, bigint nebo být typu výčtu.", "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361": "Pravá strana výrazu in musí být typu any, objektového typu nebo parametrem typu.", "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359": "Pravá strana výrazu instanceof musí mít typ any nebo typ, který se dá přiřadit k typu rozhraní Function.", - "The_shadowing_declaration_of_0_is_defined_here_18017": "Překrývající se deklarace {0} je definovaná tady.", + "The_shadowing_declaration_of_0_is_defined_here_18017": "Překrývající deklarace {0} je definovaná tady.", "The_specified_path_does_not_exist_Colon_0_5058": "Zadaná cesta neexistuje: {0}", "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541": "Cíl přiřazení musí být proměnná nebo přístup k vlastnosti.", "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778": "Cíl přiřazení rest objektu nemůže představovat přístup k nepovinné vlastnosti.", @@ -1146,6 +1151,7 @@ "This_expression_is_not_callable_2349": "Tento výraz se nedá zavolat.", "This_expression_is_not_constructable_2351": "Tento výraz se nedá vytvořit.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Tento import se nikdy nepoužívá jako hodnota a musí používat import type, protože importsNotUsedAsValues je nastavené na error.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Toto je deklarace, která se rozšiřuje. Zvažte možnost přesunout rozšiřující deklaraci do stejného souboru.", "This_may_be_converted_to_an_async_function_80006": "Toto je možné převést na asynchronní funkci.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Na tento modul je možné se pomocí importů nebo exportů ECMAScript odkazovat jen tak, že se zapne příznak {0} a odkáže se na výchozí export.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Tento modul se deklaroval pomocí export =, a když se používá příznak {0}, dá se použít jen s výchozím importem.", @@ -1208,7 +1214,7 @@ "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Typ iterovaných elementů yield* musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Typ vlastnosti {0} cyklicky odkazuje sám na sebe v mapovaném typu {1}.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Typ operandu yield v asynchronním generátoru musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.", - "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Typ pochází z tohoto importu. Import stylu oboru názvů není možné zavolat ani vytvořit a při běhu způsobí chybu. Zvažte možnost použít tady místo toho výchozí import nebo požadavek na import.", + "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Typ pochází z tohoto importu. Import stylu oboru názvů není možné zavolat ani vytvořit a při běhu způsobí chybu. Zvažte možnost použít tady místo toho výchozí import nebo importovat require.", "Type_parameter_0_has_a_circular_constraint_2313": "Parametr typu {0} má cyklické omezení.", "Type_parameter_0_has_a_circular_default_2716": "Parametr typu {0} má cyklickou výchozí hodnotu.", "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": "Parametr typu {0} signatury volání z exportovaného rozhraní má nebo používá privátní název {1}.", @@ -1270,7 +1276,7 @@ "Updating_unchanged_output_timestamps_of_project_0_6371": "Aktualizují se nezměněná výstupní časová razítka projektu {0}...", "Use_synthetic_default_member_95016": "Použije syntetického výchozího člena.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Použití řetězce v příkazu for...of se podporuje jenom v ECMAScript 5 nebo vyšší verzi.", - "Using_compiler_options_of_project_reference_redirect_0_6215": "Používají se možnosti kompilátoru přesměrování odkazu projektu {0}.", + "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", "VERSION_6036": "VERZE", "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560": "Hodnota typu {0} nemá žádné vlastnosti společné s typem {1}. Chtěli jste ji volat?", "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348": "Hodnota typu {0} se nedá volat. Nechtěli jste zahrnout new?", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index a641b1bc0c44c..092a02d46b01f 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -125,7 +125,7 @@ "Add_default_import_0_to_existing_import_declaration_from_1_90033": "Standardimport \"{0}\" zur vorhandenen Importdeklaration aus \"{1}\" hinzufügen", "Add_definite_assignment_assertion_to_property_0_95020": "Definitive Zuweisungsassertion zu Eigenschaft \"{0}\" hinzufügen", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Allen nicht initialisierten Eigenschaften definitive Zuweisungsassertionen hinzufügen", - "Add_export_to_make_this_file_into_a_module_95097": "\"export {}\" hinzufügen, um diese Datei zu einem Modul zu machen", + "Add_export_to_make_this_file_into_a_module_95097": "\"export {}\" hinzufügen, um diese Datei in ein Modul umzuwandeln", "Add_index_signature_for_property_0_90017": "Indexsignatur für die Eigenschaft \"{0}\" hinzufügen", "Add_initializer_to_property_0_95019": "Initialisierer zu Eigenschaft \"{0}\" hinzufügen", "Add_initializers_to_all_uninitialized_properties_95027": "Allen nicht initialisierten Eigenschaften Initialisierer hinzufügen", @@ -345,7 +345,7 @@ "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020": "Kompilieren Sie das dem Pfad zugewiesene Projekt zu dessen Konfigurationsdatei oder zu einem Ordner mit der Datei \"tsconfig.json\".", "Compiler_option_0_expects_an_argument_6044": "Die Compileroption \"{0}\" erwartet ein Argument.", "Compiler_option_0_requires_a_value_of_type_1_5024": "Die Compileroption \"{0}\" erfordert einen Wert vom Typ \"{1}\".", - "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Der Compiler reserviert den Namen \"{0}\", wenn er einen älteren privaten Bezeichner ausgibt.", + "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Der Compiler reserviert den Namen \"{0}\", wenn er einen privaten Bezeichner für Vorgängerversionen ausgibt.", "Composite_projects_may_not_disable_declaration_emit_6304": "In zusammengesetzten Projekten kann die Deklarationsausgabe nicht deaktiviert werden.", "Composite_projects_may_not_disable_incremental_compilation_6379": "Zusammengesetzte Projekte dürfen die inkrementelle Kompilierung nicht deaktivieren.", "Computed_property_names_are_not_allowed_in_enums_1164": "Berechnete Eigenschaftennamen sind in Enumerationen unzulässig.", @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Der Pfad \"{0}\" mit den Erweiterungen konnte nicht aufgelöst werden: {1}.", "Could_not_write_file_0_Colon_1_5033": "Die Datei \"{0}\" konnte nicht geschrieben werden. {1}.", "DIRECTORY_6038": "VERZEICHNIS", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "Die Deklaration erweitert die Deklaration in einer anderen Datei. Dieser Vorgang kann nicht serialisiert werden.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Zur Deklarationsausgabe für diese Datei muss der private Name \"{0}\" verwendet werden. Eine explizite Typanmerkung kann die Deklarationsausgabe freigeben.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Zur Deklarationsausgabe für diese Datei muss der private Name \"{0}\" aus dem Modul \"{1}\" verwendet werden. Eine explizite Typanmerkung kann die Deklarationsausgabe freigeben.", "Declaration_expected_1146": "Es wurde eine Deklaration erwartet.", @@ -611,7 +612,7 @@ "Import_declaration_0_is_using_private_name_1_4000": "Die Importdeklaration \"{0}\" verwendet den privaten Namen \"{1}\".", "Import_declaration_conflicts_with_local_declaration_of_0_2440": "Die Importdeklaration verursacht einen Konflikt mit der lokalen Deklaration von \"{0}\".", "Import_declarations_in_a_namespace_cannot_reference_a_module_1147": "Importdeklarationen in einem Namespace dürfen nicht auf ein Modul verweisen.", - "Import_default_0_from_module_1_90032": "Importstandard \"{0}\" aus Modul \"{1}\"", + "Import_default_0_from_module_1_90032": "Standard \"{0}\" aus Modul \"{1}\" importieren", "Import_emit_helpers_from_tslib_6139": "Ausgabehilfsprogramme aus \"tslib\" importieren.", "Import_may_be_converted_to_a_default_import_80003": "Der Import kann in einen Standardimport konvertiert werden.", "Import_name_cannot_be_0_2438": "Der Importname darf nicht \"{0}\" sein.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Eigenschaft \"{0}\" im Konstruktor initialisieren", "Initialize_static_property_0_90021": "Statische Eigenschaft \"{0}\" initialisieren", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "Der Initialisierer der Instanzmembervariablen \"{0}\" darf nicht auf den im Konstruktor deklarierten Bezeichner \"{1}\" verweisen.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Der Initialisierer des Parameters \"{0}\" darf nicht auf den anschließend deklarierten Bezeichner \"{1}\" verweisen.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "Der Initialisierer stellt keinen Wert für dieses Bindungselement bereit, und das Bindungselement besitzt keinen Standardwert.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Initialisierer sind in Umgebungskontexten unzulässig.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Initialisiert ein TypeScript-Projekt und erstellt eine Datei \"tsconfig.json\".", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Überladungssignaturen müssen alle exportiert oder nicht exportiert sein.", "Overload_signatures_must_all_be_optional_or_required_2386": "Überladungssignaturen müssen alle optional oder erforderlich sein.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Überladungssignaturen müssen alle öffentlich, privat oder geschützt sein.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "Auf den Parameter \"{0}\" darf in diesem Initialisierer nicht verwiesen werden.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Der Parameter \"{0}\" darf nicht auf den anschließend deklarierten Bezeichner \"{1}\" verweisen.", + "Parameter_0_cannot_reference_itself_2372": "Der Parameter \"{0}\" kann nicht auf sich selbst verweisen.", "Parameter_0_implicitly_has_an_1_type_7006": "Der Parameter \"{0}\" weist implizit einen Typ \"{1}\" auf.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Der Parameter \"{0}\" weist implizit einen Typ \"{1}\" auf, möglicherweise kann jedoch ein besserer Typ aus der Syntax abgeleitet werden.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Der Parameter \"{0}\" befindet sich nicht an der gleichen Position wie der Parameter \"{1}\".", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "Der Operand eines delete-Operators darf kein privater Bezeichner sein.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "Der Operand eines delete-Operators darf keine schreibgeschützte Eigenschaft sein.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "Der Operand eines delete-Operators muss ein Eigenschaftenverweis sein.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "Der Operand eines delete-Operators muss optional sein.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "Der Operand eines Inkrement- oder Dekrementoperators darf kein optionaler Eigenschaftenzugriff sein.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "Der Operand eines Inkrement- oder Dekrementoperators muss eine Variable oder ein Eigenschaftenzugriff sein.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "Der Parser hat eine entsprechende Klammer \"}\" zu dem hier vorhandenen Token \"{\" erwartet.", @@ -1121,7 +1123,7 @@ "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363": "Die rechte Seite einer arithmetischen Operation muss den Typ \"any\", \"number\" oder \"bigint\" aufweisen oder ein Enumerationstyp sein.", "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361": "Die rechte Seite eines in-Ausdrucks muss den Typ \"any\" aufweisen oder ein Objekttyp bzw. ein Typparameter sein.", "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359": "Die rechte Seite eines instanceof-Ausdrucks muss den Typ \"any\" oder einen Typ aufweisen, der dem Schnittstellentyp \"Function\" zugewiesen werden kann.", - "The_shadowing_declaration_of_0_is_defined_here_18017": "Die Shadowing-Deklaration von \"{0}\" ist hier definiert.", + "The_shadowing_declaration_of_0_is_defined_here_18017": "Die verbergende Deklaration von \"{0}\" ist hier definiert.", "The_specified_path_does_not_exist_Colon_0_5058": "Der angegebene Pfad \"{0}\" ist nicht vorhanden.", "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541": "Das Ziel einer Zuweisung muss eine Variable oder ein Eigenschaftenzugriff sein.", "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778": "Das Ziel einer rest-Zuweisung für ein Objekt darf kein optionaler Eigenschaftenzugriff sein.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Dieser Ausdruck kann nicht aufgerufen werden.", "This_expression_is_not_constructable_2351": "Dieser Ausdruck kann nicht erstellt werden.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Dieser Import wird nie als Wert verwendet und muss \"import type\" verwenden, weil \"importsNotUsedAsValues\" auf \"error\" festgelegt ist.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Dies ist die erweiterte Deklaration. Die erweiternde Deklaration sollte in dieselbe Datei verschoben werden.", "This_may_be_converted_to_an_async_function_80006": "Es kann eine Konvertierung in ein asynchrone Funktion durchgeführt werden.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Auf dieses Modul kann nur mit ECMAScript-Importen/-Exporten verwiesen werden, indem das Flag \"{0}\" aktiviert und auf den Standardexport verwiesen wird.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Dieses Modul wird mit \"export =\" deklariert und kann nur bei Verwendung des Flags \"{0}\" mit einem Standardimport verwendet werden.", @@ -1170,8 +1173,8 @@ "Type_0_has_no_construct_signatures_2761": "Der Typ \"{0}\" weist keine Konstruktsignaturen auf.", "Type_0_has_no_matching_index_signature_for_type_1_2537": "Der Typ \"{0}\" weist keine übereinstimmende Indexsignatur für den Typ \"{1}\" auf.", "Type_0_has_no_properties_in_common_with_type_1_2559": "Der Typ \"{0}\" verfügt über keine gemeinsamen Eigenschaften mit Typ \"{1}\".", - "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "Im Typ \"{0}\" fehlen die folgenden Eigenschaften von Typ \"{1}\": {2}", - "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "Im Typ \"{0}\" fehlen die folgenden Eigenschaften von Typ \"{1}\": {2} und {3} weitere.", + "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "Im Typ \"{0}\" fehlen die folgenden Eigenschaften von Typ \"{1}\": \"{2}\".", + "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "Im Typ \"{0}\" fehlen die folgenden Eigenschaften von Typ \"{1}\": \"{2}\" und {3} weitere.", "Type_0_is_not_a_constructor_function_type_2507": "Der Typ \"{0}\" ist kein Konstruktorfunktionstyp.", "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Der Typ \"{0}\" ist in ES5/ES3 kein gültiger Rückgabetyp einer asynchronen Funktion, weil er nicht auf einen Promise-kompatiblen Konstruktorwert verweist.", "Type_0_is_not_an_array_type_2461": "Der Typ \"{0}\" ist kein Arraytyp.", @@ -1208,7 +1211,7 @@ "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Der Typ iterierter Elemente eines \"yield*\"-Operanden muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Der Typ der Eigenschaft \"{0}\" verweist im zugeordneten Typ \"{1}\" auf sich selbst.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Der Typ eines \"yield\"-Operanden in einem asynchronen Generator muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.", - "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Der Typ stammt aus diesem Import. Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler. Erwägen Sie hier stattdessen die Verwendung eines Standardimports oder die Verwendung von \"import require\".", + "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Der Typ stammt aus diesem Import. Ein Import im Namespacestil kann nicht aufgerufen oder erstellt werden und verursacht zur Laufzeit einen Fehler. Erwägen Sie hier stattdessen die Verwendung eines Standardimports oder die den Import über \"require\".", "Type_parameter_0_has_a_circular_constraint_2313": "Der Typparameter \"{0}\" weist eine zirkuläre Einschränkung auf.", "Type_parameter_0_has_a_circular_default_2716": "Der Typparameter \"{0}\" besitzt einen zirkulären Standardwert.", "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": "Der Typparameter \"{0}\" der Aufrufsignatur aus der exportierten Schnittstelle besitzt oder verwendet den privaten Namen \"{1}\".", diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 6161ff647596e..914d8b4c7c136 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "No se pudo resolver la ruta de acceso \"{0}\" con las extensiones: {1}.", "Could_not_write_file_0_Colon_1_5033": "No se puede escribir en el archivo \"{0}\": \"{1}\".", "DIRECTORY_6038": "DIRECTORIO", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "La declaración aumenta la declaración en otro archivo. Esto no se puede serializar.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "La emisión de declaración para este archivo requiere el uso del nombre privado \"{0}\". Una anotación de tipo explícito puede desbloquear la emisión de declaración.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "La emisión de declaración para este archivo requiere el uso del nombre privado \"{0}\" del módulo \"{1}\". Una anotación de tipo explícito puede desbloquear la emisión de declaración.", "Declaration_expected_1146": "Se esperaba una declaración.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Inicializar la propiedad \"{0}\" en el constructor", "Initialize_static_property_0_90021": "Inicializar la propiedad estática \"{0}\"", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "El inicializador de la variable miembro de instancia '{0}' no puede hacer referencia al identificador '{1}' declarado en el constructor.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "El inicializador del parámetro '{0}' no puede hacer referencia al identificador '{1}' declarado después.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "El inicializador no proporciona ningún valor para este elemento de enlace que, a su vez, no tiene un valor predeterminado.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "No se permiten inicializadores en los contextos de ambiente.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Inicializa un proyecto de TypeScript y crea un archivo tsconfig.json.", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Las signaturas de sobrecarga deben ser todas exportadas o no exportadas.", "Overload_signatures_must_all_be_optional_or_required_2386": "Las signaturas de sobrecarga deben ser todas opcionales u obligatorias.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Las signaturas de sobrecarga deben ser todas públicas, privadas o protegidas.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "No se puede hacer referencia al parámetro '{0}' en su inicializador.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "El parámetro \"{0}\" no puede hacer referencia al identificador \"{1}\" declarado después de este.", + "Parameter_0_cannot_reference_itself_2372": "El parámetro \"{0}\" no puede hacer referencia a sí mismo.", "Parameter_0_implicitly_has_an_1_type_7006": "El parámetro '{0}' tiene un tipo '{1}' implícitamente.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "El parámetro \"{0}\" tiene un tipo \"{1}\" de forma implícita, pero se puede inferir un tipo más adecuado a partir del uso.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "El parámetro '{0}' no está en la misma posición que el parámetro '{1}'.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "El operando de un operador \"delete\" no puede ser un identificador privado.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "El operando de un operador \"delete\" no puede ser una propiedad de solo lectura.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "El operando de un operador \"delete\" debe ser una referencia de propiedad.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "El operando de un operador \"delete\" debe ser opcional.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "El operando de un operador de incremento o decremento no puede ser un acceso de propiedad opcional.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "El operando de un operador de incremento o decremento debe ser una variable o el acceso a una propiedad.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "El analizador esperaba encontrar un elemento \"}\" que coincidiera con el del token \"{\" aquí.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "No se puede llamar a esta expresión.", "This_expression_is_not_constructable_2351": "No se puede construir esta expresión.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Esta importación nunca se usa como valor y debe utilizar \"import type\" porque el valor \"importsNotUsedAsValues\" está establecido en \"error\".", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Esta es la declaración que se está aumentando. Considere la posibilidad de mover la declaración en aumento al mismo archivo.", "This_may_be_converted_to_an_async_function_80006": "Puede convertirse en una función asincrónica.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Solo se puede hacer referencia a este módulo con las importaciones o exportaciones de ECMAScript mediante la activación de la marca \"{0}\" y la referencia a su exportación predeterminada.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Este módulo se declara con \"export =\" y solo se puede usar con una importación predeterminada cuando se usa la marca \"{0}\".", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index 3e30dfa2928b6..ffb30aa23a74c 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Impossible de résoudre le chemin '{0}' avec les extensions {1}.", "Could_not_write_file_0_Colon_1_5033": "Impossible d'écrire le fichier '{0}' : {1}.", "DIRECTORY_6038": "RÉPERTOIRE", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "La déclaration augmente la déclaration dans un autre fichier. Cela ne peut pas être sérialisé.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "L'émission de déclaration pour ce fichier nécessite l'utilisation du nom privé '{0}'. Une annotation de type explicite peut débloquer l'émission de déclaration.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "L'émission de déclaration pour ce fichier nécessite l'utilisation du nom privé '{0}' à partir du module '{1}'. Une annotation de type explicite peut débloquer l'émission de déclaration.", "Declaration_expected_1146": "Déclaration attendue.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Initialiser la propriété '{0}' dans le constructeur", "Initialize_static_property_0_90021": "Initialiser la propriété statique '{0}'", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "L'initialiseur de la variable membre d'instance '{0}' ne peut pas référencer l'identificateur '{1}' déclaré dans le constructeur.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "L'initialiseur du paramètre '{0}' ne peut pas référencer l'identificateur '{1}' déclaré après lui.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "L'initialiseur ne fournit aucune valeur pour cet élément de liaison, et ce dernier n'a pas de valeur par défaut.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Les initialiseurs ne sont pas autorisés dans les contextes ambiants.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Initialise un projet TypeScript et crée un fichier tsconfig.json.", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Les signatures de surcharge doivent toutes être exportées ou non exportées.", "Overload_signatures_must_all_be_optional_or_required_2386": "Les signatures de surcharge doivent toutes être facultatives ou requises.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Les signatures de surcharge doivent toutes être publiques, privées ou protégées.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "Le paramètre '{0}' ne peut pas être référencé dans son initialiseur.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Le paramètre '{0}' ne peut pas référencer l'identificateur '{1}' déclaré après lui.", + "Parameter_0_cannot_reference_itself_2372": "Le paramètre '{0}' ne peut pas se référencer lui-même.", "Parameter_0_implicitly_has_an_1_type_7006": "Le paramètre '{0}' possède implicitement un type '{1}'.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Le paramètre '{0}' a implicitement un type '{1}', mais il est possible de déduire un meilleur type à partir de l'utilisation.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Le paramètre '{0}' n'est pas à la même position que le paramètre '{1}'.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "L'opérande d'un opérateur 'delete' ne peut pas être un identificateur privé.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "L'opérande d'un opérateur 'delete' ne peut pas être une propriété en lecture seule.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "L'opérande d'un opérateur 'delete' doit être une référence de propriété.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "L'opérande d'un opérateur 'delete' doit être facultatif.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "L'opérande d'un opérateur d'incrémentation ou de décrémentation ne doit pas être un accès à une propriété facultative.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "L'opérande d'un opérateur d'incrémentation ou de décrémentation doit être un accès à une variable ou une propriété.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "L'analyseur s'attendait à trouver '}' pour correspondre au jeton '{' ici.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Impossible d'appeler cette expression.", "This_expression_is_not_constructable_2351": "Impossible de construire cette expression.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Cette importation n'est jamais utilisée en tant que valeur. Elle doit utiliser 'import type', car 'importsNotUsedAsValues' a la valeur 'error'.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Ceci est la déclaration augmentée. Pensez à déplacer la déclaration d'augmentation dans le même fichier.", "This_may_be_converted_to_an_async_function_80006": "Ceci peut être converti en fonction asynchrone.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Vous pouvez référencer ce module uniquement avec les importations/exportations ECMAScript en activant l'indicateur '{0}' et en référençant son exportation par défaut.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Ce module est déclaré à l'aide de 'export =' et peut être utilisé uniquement avec une importation par défaut quand l'indicateur '{0}' est employé.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index 11e0f4f639f4d..cd2af3e393fc7 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Non è stato possibile risolvere il percorso '{0}' con le estensioni: {1}.", "Could_not_write_file_0_Colon_1_5033": "Non è stato possibile scrivere il file '{0}': {1}.", "DIRECTORY_6038": "DIRECTORY", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "La dichiarazione causa un aumento della dichiarazione in un altro file. Questa condizione non è serializzabile.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Per la creazione della dichiarazione per questo file è necessario usare il nome privato '{0}'. Un'annotazione di tipo esplicita può sbloccare la creazione della dichiarazione.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Per la creazione della dichiarazione per questo file è necessario usare il nome privato '{0}' dal modulo '{1}'. Un'annotazione di tipo esplicita può sbloccare la creazione della dichiarazione.", "Declaration_expected_1146": "È prevista la dichiarazione.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Inizializzare la proprietà '{0}' nel costruttore", "Initialize_static_property_0_90021": "Inizializzare la proprietà statica '{0}'", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "L'inizializzatore della variabile del membro di istanza '{0}' non può fare riferimento all'identificatore '{1}' dichiarato nel costruttore.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "L'inizializzatore del parametro '{0}' non può fare riferimento all'identificatore '{1}' dichiarato dopo di esso.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "L'inizializzatore non fornisce alcun valore per questo elemento di binding e per quest'ultimo non è disponibile un valore predefinito.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Gli inizializzatori non sono consentiti in contesti di ambiente.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Inizializza un progetto TypeScript e crea un file tsconfig.json.", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Le firme di overload devono essere tutte esportate o tutte non esportate.", "Overload_signatures_must_all_be_optional_or_required_2386": "Le firme di overload devono essere tutte facoltative o obbligatorie.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Le firme di overload devono essere tutte pubbliche, private o protette.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "Non è possibile fare riferimento al parametro '{0}' nel relativo inizializzatore.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Il parametro '{0}' non può fare riferimento all'identificatore '{1}' dichiarato dopo di esso.", + "Parameter_0_cannot_reference_itself_2372": "Il parametro '{0}' non può fare riferimento a se stesso.", "Parameter_0_implicitly_has_an_1_type_7006": "Il parametro '{0}' contiene implicitamente un tipo '{1}'.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Il parametro '{0}' include implicitamente un tipo '{1}', ma è possibile dedurre un tipo migliore dall'utilizzo.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Il parametro '{0}' non si trova nella stessa posizione del parametro '{1}'.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "L'operando di un operatore 'delete' non può essere un identificatore privato.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "L'operando di un operatore 'delete' non può essere una proprietà di sola lettura.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "L'operando di un operatore 'delete' deve essere un riferimento a proprietà.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "L'operando di un operatore 'delete' deve essere facoltativo.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "L'operando di un operatore di incremento o decremento non può essere un accesso a proprietà facoltativo.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "L'operando di un operatore di incremento o decremento deve essere una variabile o un accesso a proprietà.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "In questo punto il parser dovrebbe trovare un simbolo '}' abbinato al token '{'.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Questa espressione non può essere chiamata.", "This_expression_is_not_constructable_2351": "Questa espressione non può essere costruita.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Questa importazione non viene mai usata come valore e deve usare 'import type' perché 'importsNotUsedAsValues' è impostato su 'error'.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Questa è la dichiarazione che verrà aumentata. Provare a spostare la dichiarazione che causa l'aumento nello stesso file.", "This_may_be_converted_to_an_async_function_80006": "Può essere convertita in una funzione asincrona.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "È possibile fare riferimento a questo modulo solo con importazioni/esportazioni ECMAScript attivando il flag '{0}' e facendo riferimento alla relativa esportazione predefinita.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Il modulo viene dichiarato con 'export =' e può essere usato solo con un'importazione predefinita quando si usa il flag '{0}'.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 7baa1cc04baf2..54a9ac22d91e8 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "次の拡張子を持つパス '{0}' を解決できませんでした: {1}。", "Could_not_write_file_0_Colon_1_5033": "ファイル '{0}' を書き込めませんでした: '{1}'。", "DIRECTORY_6038": "ディレクトリ", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "宣言は別のファイル内の宣言を拡張します。これをシリアル化できません。", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "このファイルの宣言の生成では、プライベート名 '{0}' を使用する必要があります。明示的な型の注釈では、宣言の生成のブロックを解除できます。", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "このファイルの宣言の生成では、モジュール '{1}' からのプライベート名 '{0}' を使用する必要があります。明示的な型の注釈では、宣言の生成のブロックを解除できます。", "Declaration_expected_1146": "宣言が必要です。", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "コンストラクターのプロパティ '{0}' を初期化する", "Initialize_static_property_0_90021": "静的プロパティ '{0}' を初期化する", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "インスタンス メンバー変数 '{0}' の初期化子はコンストラクターで宣言された識別子 '{1}' を参照できません。", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "パラメーター '{0}' の初期化子はその後で宣言された識別子 '{1}' を参照できません。", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "初期化子にこのバインド要素の値が提示されていません。またバインド要素に既定値がありません。", "Initializers_are_not_allowed_in_ambient_contexts_1039": "初期化子は環境コンテキストでは使用できません。", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "TypeScript プロジェクトを初期化して、tsconfig.json ファイルを作成します。", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "オーバーロードのシグネチャはすべてがエクスポート済みであるか、またはエクスポート済みでない必要があります。", "Overload_signatures_must_all_be_optional_or_required_2386": "オーバーロードのシグネチャは、すべて省略可能であるか、すべて必須であるかのどちらかである必要があります。", "Overload_signatures_must_all_be_public_private_or_protected_2385": "オーバーロードのシグネチャはすべて、public、private、または protected でなければなりません。", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "パラメーター '{0}' はその初期化子内では参照できません。", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "パラメーター '{0}' はその後で宣言された識別子 '{1}' を参照できません。", + "Parameter_0_cannot_reference_itself_2372": "パラメーター '{0}' は、それ自体を参照できません。", "Parameter_0_implicitly_has_an_1_type_7006": "パラメーター '{0}' の型は暗黙的に '{1}' になります。", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "パラメーター '{0}' の型は暗黙的に '{1}' になっていますが、使い方からより良い型を推論できます。", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "パラメーター '{0}' がパラメーター '{1}' と同じ位置にありません。", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "'delete' 演算子のオペランドには、private 識別子を指定できません。", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "'delete' 演算子のオペランドには、読み取り専用のプロパティを指定できません。", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "'delete' 演算子のオペランドはプロパティ参照である必要があります。", + "The_operand_of_a_delete_operator_must_be_optional_2790": "'delete' 演算子のオペランドはオプションである必要があります。", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "インクリメント演算子またはデクリメント演算子のオペランドには、省略可能なプロパティ アクセスを指定することはできません。", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "インクリメントまたはデクリメント演算子のオペランドは、変数またはプロパティ アクセスである必要があります。", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "パーサーは、ここで '{' トークンに一致する '}' を予期していました。", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "この式は呼び出し可能ではありません。", "This_expression_is_not_constructable_2351": "この式はコンストラクト可能ではありません。", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "このインポートは値として使用されることはありません。'importsNotUsedAsValues' が 'error' に設定されているため、'import type' を使用する必要があります。", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "これは拡張される宣言です。拡張する側の宣言を同じファイルに移動することを検討してください。", "This_may_be_converted_to_an_async_function_80006": "これは非同期関数に変換できます。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "このモジュールは、'{0}' フラグをオンにして既定のエクスポートを参照することにより、ECMAScript のインポートまたはエクスポートのみを使用して参照できます。", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "このモジュールは 'export =' を使用して宣言されていて、'{0}' フラグを使用する場合は既定のインポートでのみ使用できます。", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index 2764265b2b068..91b55b710f598 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "{1} 확장이 포함된 '{0}' 경로를 확인할 수 없습니다.", "Could_not_write_file_0_Colon_1_5033": "'{0}' 파일을 쓸 수 없습니다. '{1}'.", "DIRECTORY_6038": "디렉터리", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "선언이 다른 파일의 선언을 확대합니다. 직렬화할 수 없습니다.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "이 파일의 선언 내보내기에는 프라이빗 이름 '{0}'을(를) 사용해야 합니다. 명시적 형식 주석은 선언 내보내기를 차단 해제할 수 있습니다.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "이 파일의 선언 내보내기에는 '{1}' 모듈의 프라이빗 이름 '{0}'을(를) 사용해야 합니다. 명시적 형식 주석은 선언 내보내기를 차단 해제할 수 있습니다.", "Declaration_expected_1146": "선언이 필요합니다.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "생성자에서 속성 '{0}' 초기화", "Initialize_static_property_0_90021": "정적 속성 '{0}' 초기화", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "인스턴스 멤버 변수 '{0}'의 이니셜라이저는 생성자에 선언된 식별자 '{1}'을(를) 참조할 수 없습니다.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "매개 변수 '{0}'의 이니셜라이저는 그 다음에 선언된 식별자 '{1}'을(를) 참조할 수 없습니다.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "이니셜라이저는 이 바인딩 요소에 대한 값을 제공하지 않으며 바인딩 요소에는 기본값이 없습니다.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "앰비언트 컨텍스트에서는 이니셜라이저가 허용되지 않습니다.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "TypeScript 프로젝트를 초기화하고 tsconfig.json 파일을 만듭니다.", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "오버로드 시그니처는 모두 내보내거나 모두 내보내지 않아야 합니다.", "Overload_signatures_must_all_be_optional_or_required_2386": "오버로드 시그니처는 모두 선택 사항이거나 필수 사항이어야 합니다.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "오버로드 시그니처는 모두 퍼블릭, 프라이빗 또는 보호된 상태여야 합니다.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "매개 변수 '{0}'은(는) 해당 이니셜라이저에서 참조할 수 없습니다.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "매개 변수 '{0}'은(는) 이 매개 변수 뒤에 선언된 식별자 '{1}'을(를) 참조할 수 없습니다.", + "Parameter_0_cannot_reference_itself_2372": "매개 변수 '{0}'은(는) 자신을 참조할 수 없습니다.", "Parameter_0_implicitly_has_an_1_type_7006": "'{0}' 매개 변수에는 암시적으로 '{1}' 형식이 포함됩니다.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "'{0}' 매개 변수는 암시적으로 '{1}' 형식이지만, 사용량에서 더 나은 형식을 유추할 수 있습니다.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "'{0}' 매개 변수는 '{1}' 매개 변수와 같은 위치에 있지 않습니다.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "'delete' 연산자의 피연산자는 프라이빗 식별자일 수 없습니다.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "'delete' 연산자의 피연산자는 읽기 전용 속성일 수 없습니다.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "'delete' 연산자의 피연산자는 속성 참조여야 합니다.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "'delete' 연산자의 피연산자는 선택 사항이어야 합니다.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "증분 또는 감소 연산자의 피연산자는 선택적 속성 액세스일 수 없습니다.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "증가 또는 감소 연산자의 피연산자는 변수 또는 속성 액세스여야 합니다.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "여기서 파서는 '{' 토큰과 일치하는 '}'를 찾아야 합니다.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "이 식은 호출할 수 없습니다.", "This_expression_is_not_constructable_2351": "이 식은 생성할 수 없습니다.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "이 가져오기는 값으로 사용되지 않아야 하며 'importsNotUsedAsValues'가 'error'로 설정되어 있기 때문에 'import type'을 사용해야 합니다.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "확대되는 선언입니다. 확대하는 선언을 같은 파일로 이동하는 것이 좋습니다.", "This_may_be_converted_to_an_async_function_80006": "비동기 함수로 변환될 수 있습니다.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "이 모듈은 '{0}' 플래그를 켜고 기본 내보내기를 참조하여 ECMAScript 가져오기/내보내기를 통해서만 참조할 수 있습니다.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "이 모듈은 'export ='를 사용하여 선언되었으며 '{0}' 플래그를 사용하는 경우에만 기본 가져오기와 함께 사용할 수 있습니다.", diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index 425fdb6ec524a..7a0f57a78e756 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -44,7 +44,7 @@ "A_generator_cannot_have_a_void_type_annotation_2505": "Generator nie może mieć adnotacji typu „void”.", "A_get_accessor_cannot_have_parameters_1054": "Metoda dostępu „get” nie może mieć parametrów.", "A_get_accessor_must_return_a_value_2378": "Metoda dostępu „get” musi zwracać wartość.", - "A_label_is_not_allowed_here_1344": "„Etykieta nie jest dozwolona w tym miejscu.", + "A_label_is_not_allowed_here_1344": "Etykieta nie jest dozwolona w tym miejscu.", "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651": "Inicjator składowej w deklaracji wyliczenia nie może przywoływać składowych zadeklarowanych po nim, w tym składowych zdefiniowanych w innych wyliczeniach.", "A_method_cannot_be_named_with_a_private_identifier_18022": "Metody nie można nazwać za pomocą identyfikatora prywatnego.", "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545": "Klasa mixin musi mieć konstruktor z pojedynczym parametrem rest o typie „any[]”.", @@ -345,7 +345,7 @@ "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020": "Skompiluj projekt z uwzględnieniem ścieżki jego pliku konfiguracji lub folderu z plikiem „tsconfig.json”.", "Compiler_option_0_expects_an_argument_6044": "Opcja kompilatora „{0}” oczekuje argumentu.", "Compiler_option_0_requires_a_value_of_type_1_5024": "Opcja kompilatora „{0}” wymaga wartości typu {1}.", - "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Kompilator rezerwuje nazwę „{0}” podczas emitowania niższego poziomu identyfikatora prywatnego.", + "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "Kompilator rezerwuje nazwę „{0}” podczas emitowania identyfikatora prywatnego na niższy poziom.", "Composite_projects_may_not_disable_declaration_emit_6304": "Projekty kompozytowe nie mogą wyłączyć emitowania deklaracji.", "Composite_projects_may_not_disable_incremental_compilation_6379": "Projekty złożone nie mogą wyłączać kompilacji przyrostowej.", "Computed_property_names_are_not_allowed_in_enums_1164": "Obliczone nazwy właściwości nie są dozwolone w wyliczeniach.", @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Nie można rozpoznać ścieżki „{0}” z rozszerzeniami: {1}.", "Could_not_write_file_0_Colon_1_5033": "Nie można zapisać pliku „{0}”: {1}.", "DIRECTORY_6038": "KATALOG", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "Deklaracja rozszerza deklarację w innym pliku. Nie można przeprowadzić serializacji.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Emitowanie deklaracji dla tego pliku wymaga użycia nazwy prywatnej „{0}”. Jawna adnotacja typu może odblokować emitowanie deklaracji.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Emitowanie deklaracji dla tego pliku wymaga użycia nazwy prywatnej „{0}” z modułu „{1}”. Jawna adnotacja typu może odblokować emitowanie deklaracji.", "Declaration_expected_1146": "Oczekiwano deklaracji.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Zainicjuj właściwość „{0}” w konstruktorze", "Initialize_static_property_0_90021": "Zainicjuj właściwość statyczną „{0}”", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "Inicjator zmiennej składowej wystąpienia „{0}” nie może przywoływać identyfikatora „{1}” zadeklarowanego w konstruktorze.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Inicjator parametru „{0}” nie może przywoływać identyfikatora „{1}” zadeklarowanego po nim.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "Inicjator nie określa żadnej wartości dla tego elementu powiązania, a element powiązania nie ma wartości domyślnej.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Inicjatory są niedozwolone w otaczających kontekstach.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Inicjuje projekt TypeScript i tworzy plik tsconfig.json.", @@ -802,13 +802,14 @@ "Output_directory_for_generated_declaration_files_6166": "Katalog wyjściowy dla wygenerowanych plików deklaracji.", "Output_file_0_from_project_1_does_not_exist_6309": "Plik wyjściowy „{0}” z projektu „{1}” nie istnieje", "Output_file_0_has_not_been_built_from_source_file_1_6305": "Plik wyjściowy „{0}” nie został utworzony na podstawie pliku źródłowego „{1}”.", - "Overload_0_of_1_2_gave_the_following_error_2772": "Przeciążenie {0} {1}, „{2}”, dało następujący błąd.", + "Overload_0_of_1_2_gave_the_following_error_2772": "Przeciążenie {0} z {1}, „{2}”, zwróciło następujący błąd.", "Overload_signatures_must_all_be_abstract_or_non_abstract_2512": "Wszystkie sygnatury przeciążeń muszą być abstrakcyjne lub nieabstrakcyjne.", "Overload_signatures_must_all_be_ambient_or_non_ambient_2384": "Wszystkie sygnatury przeciążeń muszą być otaczającymi sygnaturami lub żadna nie może być otaczającą sygnaturą.", "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Wszystkie sygnatury przeciążeń muszą być wyeksportowane lub żadna nie może być wyeksportowana.", "Overload_signatures_must_all_be_optional_or_required_2386": "Wszystkie sygnatury przeciążeń muszą być opcjonalne lub wymagane.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Wszystkie sygnatury przeciążeń muszą być publiczne, prywatne lub chronione.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "Parametr „{0}” nie może być przywoływany w swoim inicjatorze.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Parametr „{0}” nie może przywoływać identyfikatora „{1}” zadeklarowanego po nim.", + "Parameter_0_cannot_reference_itself_2372": "Parametr „{0}” nie może odwoływać się do siebie samego.", "Parameter_0_implicitly_has_an_1_type_7006": "Dla parametru „{0}” niejawnie określono typ „{1}”.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Parametr „{0}” niejawnie ma typ „{1}”, ale lepszy typ można wywnioskować na podstawie użycia.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Parametr „{0}” nie znajduje się w tym samym położeniu co parametr „{1}”.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "Operand operatora „delete” nie może być identyfikatorem prywatnym.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "Operand operatora „delete” nie może być właściwością tylko do odczytu.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "Operand operatora „delete” musi być odwołaniem do właściwości.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "Operand operatora „delete” musi być opcjonalny.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "Operand operatora inkrementacji lub dekrementacji nie może być opcjonalnym dostępem do właściwości.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "Operand operatora inkrementacji lub dekrementacji musi być zmienną lub dostępem do właściwości.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "Analizator oczekiwał odnalezienia elementu „}” w celu dopasowania do tokenu „{” w tym miejscu.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "To wyrażenie nie jest wywoływalne.", "This_expression_is_not_constructable_2351": "Tego wyrażenia nie można skonstruować.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Ten import nigdy nie jest używany jako wartość i musi używać aliasu „import type”, ponieważ opcja „importsNotUsedAsValues” jest ustawiona na wartość „error”.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "To jest rozszerzana deklaracja. Rozważ przeniesienie deklaracji rozszerzenia do tego samego pliku.", "This_may_be_converted_to_an_async_function_80006": "To można przekonwertować na funkcję asynchroniczną.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Do tego modułu można odwoływać się tylko za pomocą importów/eksportów języka ECMAScript, włączając flagę „{0}” i odwołując się do jego eksportu domyślnego.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Ten moduł jest zadeklarowany przy użyciu składni „export =” i może być używany tylko z importem domyślnym, gdy jest używana flaga „{0}”.", @@ -1171,7 +1174,7 @@ "Type_0_has_no_matching_index_signature_for_type_1_2537": "Typ „{0}” nie ma pasującej sygnatury indeksu dla typu „{1}”.", "Type_0_has_no_properties_in_common_with_type_1_2559": "Typy „{0}” i „{1}” nie mają żadnych wspólnych właściwości.", "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "W typie „{0}” brakuje następujących właściwości z typu „{1}”: {2}", - "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "W typie „{0}” brakuje następujących właściwości typu „{1}”: {2} i {3} więcej.", + "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "W typie „{0}” brakuje następujących właściwości z typu „{1}”: {2} i jeszcze {3}.", "Type_0_is_not_a_constructor_function_type_2507": "Typ „{0}” nie jest typem funkcji konstruktora.", "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Typ „{0}” nie jest prawidłowym zwracanym typem funkcji asynchronicznej w wersji ES5/ES3, ponieważ nie odwołuje się do wartości konstruktora zgodnej z elementem Promise.", "Type_0_is_not_an_array_type_2461": "Typ „{0}” nie jest typem tablicowym.", @@ -1270,7 +1273,7 @@ "Updating_unchanged_output_timestamps_of_project_0_6371": "Trwa aktualizowanie niezmienionych sygnatur czasowych danych wyjściowych projektu „{0}”...", "Use_synthetic_default_member_95016": "Użyj syntetycznej składowej „default”.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Używanie ciągu w instrukcji „for...of” jest obsługiwane tylko w języku ECMAScript 5 lub nowszym.", - "Using_compiler_options_of_project_reference_redirect_0_6215": "Używanie opcji kompilatora przekierowania odwołania do projektu „{0}”.", + "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", "VERSION_6036": "WERSJA", "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560": "Wartość typu „{0}” nie ma żadnych wspólnych właściwości z typem „{1}”. Czy jej wywołanie było zamierzone?", "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348": "Nie można wywołać wartości typu „{0}”. Czy miał zostać użyty operator „new”?", diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index 1b918e0416cda..b9e4fdd72e28f 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -345,7 +345,7 @@ "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020": "Compile o projeto dando o caminho para seu arquivo de configuração ou para uma pasta com um 'tsconfig.json'.", "Compiler_option_0_expects_an_argument_6044": "A opção do compilador '{0}' espera um argumento.", "Compiler_option_0_requires_a_value_of_type_1_5024": "A opção do compilador '{0}' requer um valor do tipo {1}.", - "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "O compilador reserva o nome '{0}' ao emitir um nível inferior de identificador privado.", + "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027": "O compilador reserva o nome '{0}' ao emitir um identificador privado para versões anteriores.", "Composite_projects_may_not_disable_declaration_emit_6304": "Projetos compostos não podem desabilitar a emissão de declaração.", "Composite_projects_may_not_disable_incremental_compilation_6379": "Projetos compostos podem não desabilitar a compilação incremental.", "Computed_property_names_are_not_allowed_in_enums_1164": "Nomes de propriedade calculados não são permitidos em enums.", @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Não foi possível resolver o caminho '{0}' com as extensões: {1}.", "Could_not_write_file_0_Colon_1_5033": "Não foi possível gravar o arquivo '{0}': {1}.", "DIRECTORY_6038": "DIRETÓRIO", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "A declaração aumenta a declaração em outro arquivo. Isso não pode ser serializado.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "A emissão de declaração para esse arquivo requer o uso do nome privado '{0}'. Uma anotação de tipo explícita pode desbloquear a emissão de declaração.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "A emissão de declaração para esse arquivo requer o uso do nome privado '{0}' do módulo '{1}'. Uma anotação de tipo explícita pode desbloquear a emissão de declaração.", "Declaration_expected_1146": "Declaração esperada.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Inicializar a propriedade '{0}' no construtor", "Initialize_static_property_0_90021": "Inicializar a propriedade estática '{0}'", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "O inicializador da variável de membro de instância '{0}' não pode referenciar o identificador '{1}' declarado no construtor.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "O inicializador do parâmetro '{0}' não pode referenciar o identificador '{1}' declarado depois dele.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "O inicializador não fornece um valor para esse elemento de associação e o elemento de associação não tem valor padrão.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Inicializadores não são permitidos em contextos de ambiente.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Inicializa um projeto TypeScript e cria um arquivo tsconfig.json.", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Assinaturas de sobrecarga devem todas ser exportadas ou não exportadas.", "Overload_signatures_must_all_be_optional_or_required_2386": "Todas as assinaturas de sobrecarga devem ser opcionais ou obrigatórias.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Todas as assinaturas de sobrecarga devem ser protegidas, privadas ou públicas.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "O parâmetro '{0}' não pode ser referenciado em seu inicializador.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "O parâmetro '{0}' não pode referenciar o identificador '{1}' declarado depois dele.", + "Parameter_0_cannot_reference_itself_2372": "O parâmetro '{0}' não pode referenciar a si mesmo.", "Parameter_0_implicitly_has_an_1_type_7006": "O parâmetro '{0}' implicitamente tem um tipo '{1}'.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "O parâmetro '{0}' implicitamente tem um tipo '{1}', mas um tipo melhor pode ser inferido do uso.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "O parâmetro '{0}' não está na mesma posição que o parâmetro '{1}'.", @@ -848,7 +849,7 @@ "Prefix_0_with_an_underscore_90025": "Prefixo '{0}' com um sublinhado", "Prefix_all_incorrect_property_declarations_with_declare_95095": "Prefixar todas as declarações de propriedade incorretas com 'declare'", "Prefix_all_unused_declarations_with_where_possible_95025": "Prefixar com '_' todas as declarações não usadas quando possível", - "Prefix_with_declare_95094": "Prefixo com 'declare'", + "Prefix_with_declare_95094": "Prefixar com 'declare'", "Print_names_of_files_part_of_the_compilation_6155": "Nomes de impressão das partes dos arquivos da compilação.", "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503": "Imprima nomes de arquivos que fazem parte da compilação e, em seguida, interrompa o processamento.", "Print_names_of_generated_files_part_of_the_compilation_6154": "Nomes de impressão das partes dos arquivos gerados da compilação.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "O operando de um operador 'delete' pode não ser um identificador privado.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "O operando de um operador 'delete' não pode ser uma propriedade somente leitura.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "O operando de um operador 'delete' deve ser uma referência de propriedade.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "O operando de um operador 'delete' precisa ser opcional.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "O operando de um operador de incremento ou decremento pode não ser um acesso opcional de propriedade.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "O operando de um operador de incremento ou decremento deve ser uma variável ou um acesso à propriedade.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "O analisador esperava localizar um '}' para corresponder ao token '{' aqui.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Essa expressão não pode ser chamada.", "This_expression_is_not_constructable_2351": "Essa expressão não pode ser construída.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Essa importação nunca é usada como um valor e deve usar 'tipo de importação' porque 'importsNotUsedAsValues' está definido como 'erro'.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Esta é a declaração que está sendo aumentada. Considere mover a declaração em aumento para o mesmo arquivo.", "This_may_be_converted_to_an_async_function_80006": "Isso pode ser convertido em uma função assíncrona.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Esse módulo só pode ser referenciado com importações/exportações de ECMAScript ligando o sinalizador '{0}' e referenciando sua exportação padrão.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Esse módulo é declarado com o uso de 'export =' e só pode ser usado com uma importação padrão ao usar o sinalizador '{0}'.", @@ -1208,7 +1211,7 @@ "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "O tipo de elementos iterados de um operando \"yield*\" deve ser uma promessa válida ou não deve conter um membro \"then\" que pode ser chamado.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "O tipo de propriedade '{0}' faz referência circular a si mesmo no tipo mapeado '{1}'.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "O tipo do operando \"yield\" em um gerador assíncrono deve ser uma promessa válida ou não deve conter um membro \"then\" que pode ser chamado.", - "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "O tipo se origina nessa importação. Uma importação de estilo de namespace não pode ser chamada nem construída e causará uma falha no runtime. Considere usar uma importação padrão ou solicite uma importação aqui.", + "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "O tipo se origina nessa importação. Uma importação de estilo de namespace não pode ser chamada nem construída e causará uma falha no runtime. Considere usar uma importação padrão ou importe require aqui.", "Type_parameter_0_has_a_circular_constraint_2313": "O parâmetro de tipo '{0}' tem uma restrição circular.", "Type_parameter_0_has_a_circular_default_2716": "O parâmetro de tipo '{0}' tem um padrão circular.", "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": "O parâmetro de tipo '{0}' da assinatura de chamada da interface exportada tem ou está usando o nome particular '{1}'.", @@ -1270,7 +1273,7 @@ "Updating_unchanged_output_timestamps_of_project_0_6371": "Atualizando os carimbos de data/hora de saída inalterados do projeto '{0}'...", "Use_synthetic_default_member_95016": "Use o membro sintético 'padrão'.", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Há suporte para o uso de uma cadeia de caracteres em uma instrução 'for...of' somente no ECMAScript 5 e superior.", - "Using_compiler_options_of_project_reference_redirect_0_6215": "Usando opções de compilador de redirecionamento de referência de projeto '{0}'.", + "Using_compiler_options_of_project_reference_redirect_0_6215": "Using compiler options of project reference redirect '{0}'.", "VERSION_6036": "VERSÃO", "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560": "O valor do tipo '{0}' não tem propriedades em comum com o tipo '{1}'. Você queria chamá-lo?", "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348": "O valor do tipo '{0}' não pode ser chamado. Você pretendia incluir 'new'?", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index a1dea78b0f9bd..18c10e5edad46 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -125,7 +125,7 @@ "Add_default_import_0_to_existing_import_declaration_from_1_90033": "Добавление импорта \"{0}\" по умолчанию в существующее объявление импорта из \"{1}\"", "Add_definite_assignment_assertion_to_property_0_95020": "Добавить утверждение определенного назначения к свойству \"{0}\"", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Добавить утверждения определенного назначения ко всем неинициализированным свойствам", - "Add_export_to_make_this_file_into_a_module_95097": "Добавить \"export {}\", чтобы сделать этот файл модулем", + "Add_export_to_make_this_file_into_a_module_95097": "Добавить \"export {}\", чтобы превратить этот файл в модуль", "Add_index_signature_for_property_0_90017": "Добавьте сигнатуру индекса для свойства \"{0}\"", "Add_initializer_to_property_0_95019": "Добавить инициализатор к свойству \"{0}\"", "Add_initializers_to_all_uninitialized_properties_95027": "Добавить инициализаторы ко всем неинициализированным свойствам", @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Не удалось разрешить путь \"{0}\" с расширениями: {1}.", "Could_not_write_file_0_Colon_1_5033": "Не удалось записать файл \"{0}\": \"{1}\".", "DIRECTORY_6038": "КАТАЛОГ", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "Объявление дополняет объявление в другом файле. Сериализация невозможна.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Для порождения объявления для этого файла требуется использовать закрытое имя \"{0}\". Явная заметка с типом может разблокировать порождение объявления.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Для порождения объявления для этого файла требуется использовать закрытое имя \"{0}\" из модуля \"{1}\". Явная заметка с типом может разблокировать порождение объявления.", "Declaration_expected_1146": "Ожидалось объявление.", @@ -611,7 +612,7 @@ "Import_declaration_0_is_using_private_name_1_4000": "Объявление импорта \"{0}\" использует закрытое имя \"{1}\".", "Import_declaration_conflicts_with_local_declaration_of_0_2440": "Объявление импорта конфликтует с локальным объявлением \"{0}\".", "Import_declarations_in_a_namespace_cannot_reference_a_module_1147": "Объявления импорта в пространстве имен не могут иметь ссылки на модуль.", - "Import_default_0_from_module_1_90032": "Импорт \"{0}\" по умолчанию из модуля \"{1}\"", + "Import_default_0_from_module_1_90032": "Импортировать \"{0}\" по умолчанию из модуля \"{1}\"", "Import_emit_helpers_from_tslib_6139": "Импорт вспомогательных объектов, участвующих в порождении, из \"tslib\".", "Import_may_be_converted_to_a_default_import_80003": "Импорт можно преобразовать в импорт по умолчанию.", "Import_name_cannot_be_0_2438": "Имя импорта не может иметь значение \"{0}\".", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Инициализируйте свойство \"{0}\" в конструкторе", "Initialize_static_property_0_90021": "Инициализируйте статическое свойство \"{0}\"", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "Инициализатор переменной-элемента экземпляра \"{0}\" не может ссылаться на идентификатор \"{1}\", объявленный в конструкторе.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Инициализатор параметра \"{0}\" не может ссылаться на идентификатор \"{1}\", объявленный после него.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "Инициализатор не предоставляет значения для элемента привязки, который не имеет значения по умолчанию.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Инициализаторы не разрешены в окружающих контекстах.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Инициализирует проект TypeScript и создает файл \"tsconfig.json\".", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Сигнатуры перегрузки должны быть экспортированы и не экспортированы.", "Overload_signatures_must_all_be_optional_or_required_2386": "Все сигнатуры перегрузки должны быть либо необязательными, либо обязательными.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Все сигнатуры перегрузки должны быть либо общими, либо закрытыми, либо защищенными.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "На параметр \"{0}\" невозможно ссылаться в его инициализаторе.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "Параметр \"{0}\" не может ссылаться на идентификатор \"{1}\", объявленный после него.", + "Parameter_0_cannot_reference_itself_2372": "Параметр \"{0}\" не может ссылаться сам на себя.", "Parameter_0_implicitly_has_an_1_type_7006": "Параметр \"{0}\" неявно имеет тип \"{1}\".", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "Параметр \"{0}\" неявно имеет тип \"{1}\", но из использования можно определить более подходящий тип.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "Параметр \"{0}\" находится в позиции, отличной от позиции параметра \"{1}\".", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "Операнд оператора \"delete\" не может быть закрытым идентификатором.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "Операнд оператора \"delete\" не может быть свойством только для чтения.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "Операнд оператора \"delete\" должен быть ссылкой на свойство.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "Операнд оператора \"delete\" должен быть необязательным.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "Операнд оператора инкремента или декремента не может быть обращением к необязательному свойству.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "Операнд оператора инкремента или декремента должен быть переменной или доступом к свойству.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "Анализатор ожидал найти \"}\" для соответствия указанному здесь токену \"{\".", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Это выражение не является вызываемым.", "This_expression_is_not_constructable_2351": "Это выражение не может быть построено.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "Этот импорт никогда не используется в качестве значения и должен использовать \"import type\", так как для \"importsNotUsedAsValues\" задано значение \"error\".", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Это объявление дополняется другим объявлением. Попробуйте переместить дополняющее объявление в тот же файл.", "This_may_be_converted_to_an_async_function_80006": "Это можно преобразовать в асинхронную функцию.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "На этот модуль можно ссылаться только с помощью импортов/экспортов ECMAScript, включив флаг \"{0}\" и сославшись на его экспорт по умолчанию.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Этот модуль объявлен с помощью \"export =\" и может использоваться только с импортом по умолчанию при использовании флага \"{0}\".", @@ -1170,7 +1173,7 @@ "Type_0_has_no_construct_signatures_2761": "Тип \"{0}\" не содержит сигнатуры конструкции.", "Type_0_has_no_matching_index_signature_for_type_1_2537": "Тип \"{0}\" не содержит соответствующую сигнатуру индекса для типа \"{1}\".", "Type_0_has_no_properties_in_common_with_type_1_2559": "У типа \"{0}\" нет общих свойств с типом \"{1}\".", - "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "В типе \"{0}\" отсутствуют следующие свойства из типа \"{1}\": {2}.", + "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_2739": "В типе \"{0}\" отсутствуют следующие свойства из типа \"{1}\": {2}", "Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more_2740": "В типе \"{0}\" отсутствуют следующие свойства из типа \"{1}\": {2} и еще {3}.", "Type_0_is_not_a_constructor_function_type_2507": "Тип \"{0}\" не является типом функции конструктора.", "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055": "Тип \"{0}\" не является допустимым типом возвращаемого значения асинхронной функции в ES5/ES3, так как он не ссылается на значение конструктора, совместимое с Promise.", @@ -1208,7 +1211,7 @@ "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Тип элементов итерации для операнда \"yield*\" должен быть допустимым обещанием либо не должен содержать вызываемый элемент \"then\".", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Тип свойства \"{0}\" циклически ссылается на самого себя в сопоставленном типе \"{1}\".", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Тип операнда \"yield\" в асинхронном генераторе должен быть допустимым обещанием либо не должен содержать вызываемый элемент \"then\".", - "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Тип происходит от этого импорта. Импорт стиля пространства имен не может быть вызван или создан и приведет к сбою во время выполнения. Вместо этого рекомендуется использовать импорт по умолчанию или импорт, указанный здесь.", + "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Тип происходит от этого импорта. Импорт стиля пространства имен не может быть вызван или создан и приведет к сбою во время выполнения. Вместо этого рекомендуется использовать импорт по умолчанию или импортировать сюда \"require\".", "Type_parameter_0_has_a_circular_constraint_2313": "Параметр типа \"{0}\" содержит циклическое ограничение.", "Type_parameter_0_has_a_circular_default_2716": "Параметр типа \"{0}\" по умолчанию является циклическим.", "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": "Параметр типа \"{0}\" сигнатуры вызова из экспортированного интерфейса имеет или использует закрытое имя \"{1}\".", @@ -1270,7 +1273,7 @@ "Updating_unchanged_output_timestamps_of_project_0_6371": "Обновление меток времени в неизменившихся выходных данных проекта \"{0}\"...", "Use_synthetic_default_member_95016": "Используйте искусственный элемент \"default\".", "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494": "Использование строки для оператора for...of поддерживается только в ECMAScript 5 и более поздних версиях.", - "Using_compiler_options_of_project_reference_redirect_0_6215": "Использование параметров компилятора перенаправления ссылки на проект \"{0}\".", + "Using_compiler_options_of_project_reference_redirect_0_6215": "Использование параметров компилятора для перенаправления ссылки на проект \"{0}\".", "VERSION_6036": "ВЕРСИЯ", "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560": "Значение типа \"{0}\" не имеет общих свойств со значением типа \"{1}\". Вы хотели вызвать его?", "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348": "Значение типа \"{0}\" не может вызываться. Вы хотели использовать new?", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index dad740b067d63..1d42b744ce6b6 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "Uzantılara sahip '{0}' yolu çözümlenemedi: {1}.", "Could_not_write_file_0_Colon_1_5033": "'{0}' dosyası yazılamadı: {1}.", "DIRECTORY_6038": "DİZİN", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "Bildirim başka bir dosyadaki bildirimi genişlettiğinden serileştirilemez.", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "Bu dosya için bildirim gösterme, '{0}' özel adını kullanmayı gerektiriyor. Açık tür ek açıklaması, bildirim gösterme engelini kaldırabilir.", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "Bu dosya için bildirim gösterme, '{1}' modülündeki '{0}' özel adını kullanmayı gerektiriyor. Açık tür ek açıklaması, bildirim gösterme engelini kaldırabilir.", "Declaration_expected_1146": "Bildirim bekleniyor.", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "Oluşturucu içinde '{0}' özelliğini başlat", "Initialize_static_property_0_90021": "'{0}' statik özelliğini başlat", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "'{0}' örnek üyesi değişkeninin başlatıcısı, oluşturucuda bildirilen '{1}' tanımlayıcısına başvuramaz.", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "'{0}' parametresinin başlatıcısı, kendinden sonra bildirilen '{1}' tanımlayıcısına başvuramaz.", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "Başlatıcı bu bağlama öğesi için bir değer sağlamıyor ve bağlama öğesi varsayılan değere sahip değil.", "Initializers_are_not_allowed_in_ambient_contexts_1039": "Çevresel bağlamlarda başlatıcılara izin verilmez.", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "Bir TypeScript projesi başlatır ve bir tsconfig.json dosyası oluşturur.", @@ -802,13 +802,14 @@ "Output_directory_for_generated_declaration_files_6166": "Oluşturulan bildirim dosyaları için çıkış dizini.", "Output_file_0_from_project_1_does_not_exist_6309": "'{1}' projesinden '{0}' çıkış dosyası yok", "Output_file_0_has_not_been_built_from_source_file_1_6305": "Çıkış dosyası '{0}' '{1}' kaynak dosyasından oluşturulmamış.", - "Overload_0_of_1_2_gave_the_following_error_2772": "{1} metodunun {0} aşırı yüklemesi ('{2}'), aşağıdaki hatayı verdi.", + "Overload_0_of_1_2_gave_the_following_error_2772": "{0}/{1} aşırı yükleme '{2}' imzası, aşağıdaki hatayı verdi.", "Overload_signatures_must_all_be_abstract_or_non_abstract_2512": "Aşırı yükleme imzalarının hepsi soyut veya soyut olmayan olmalıdır.", "Overload_signatures_must_all_be_ambient_or_non_ambient_2384": "Aşırı yükleme imzalarının tümü çevresel veya çevresel olmayan türde olmalıdır.", "Overload_signatures_must_all_be_exported_or_non_exported_2383": "Aşırı yükleme imzalarının hepsi dışarı aktarılmış veya dışarı aktarılmamış olmalıdır.", "Overload_signatures_must_all_be_optional_or_required_2386": "Aşırı yükleme imzalarının tümü isteğe bağlı veya gerekli olmalıdır.", "Overload_signatures_must_all_be_public_private_or_protected_2385": "Aşırı yükleme imzalarının tümü ortak, özel veya korumalı olmalıdır.", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "'{0}' parametresine başlatıcısında başvurulamaz.", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "'{0}' parametresi, kendisinden sonra bildirilen '{1}' tanımlayıcısına başvuramaz.", + "Parameter_0_cannot_reference_itself_2372": "'{0}' parametresi kendisine başvuramaz.", "Parameter_0_implicitly_has_an_1_type_7006": "'{0}' parametresi örtük olarak '{1}' türüne sahip.", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "'{0}' parametresi örtük olarak bir '{1}' türüne sahip ancak kullanımdan daha iyi bir tür çıkarsanabilir.", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "'{0}' parametresi, '{1}' parametresi ile aynı konumda değil.", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "'delete' operatörünün işleneni özel bir tanımlayıcı olamaz.", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "'delete' operatörünün işleneni, salt okunur bir özellik olamaz.", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "'delete' operatörünün işleneni, bir özellik başvurusu olmalıdır.", + "The_operand_of_a_delete_operator_must_be_optional_2790": "'delete' operatörünün işleneni isteğe bağlı olmalıdır.", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "Artırma veya eksiltme operatörünün işleneni, isteğe bağlı bir özellik erişimi olamaz.", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "Artırma veya eksiltme operatörünün işleneni, bir değişken veya özellik erişimi olmalıdır.", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "Ayrıştırıcı, buradaki '{' belirteciyle eşleştirmek için bir '}' bulmayı bekliyordu.", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "Bu ifade çağrılabilir değil.", "This_expression_is_not_constructable_2351": "Bu ifade oluşturulabilir değil.", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "'importsNotUsedAsValues', 'error' olarak ayarlandığından bu içeri aktarma hiçbir zaman bir değer olarak kullanılmaz ve 'import type' kullanmalıdır.", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "Bu, genişletilmekte olan bildirimdir. Genişleten bildirimi aynı dosyaya taşımayı düşünün.", "This_may_be_converted_to_an_async_function_80006": "Bu, asenkron bir işleve dönüştürülebilir.", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "Bu modüle yalnızca '{0}' bayrağını açıp modülün varsayılan dışarı aktarma işlemine başvurarak ECMAScript içeri/dışarı aktarma işlemleri ile başvurulabilir.", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "Bu modül, 'export =' kullanılarak bildirildi ve yalnızca '{0}' bayrağı kullanılırken varsayılan bir içeri aktarma ile kullanılabilir.", @@ -1208,7 +1211,7 @@ "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Bir 'yield*' işleneninin yinelenen öğelerinin türü, geçerli bir promise olmalı veya çağrılabilir 'then' üyesi içermemelidir.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "'{0}' özelliğinin türü, '{1}' eşlenmiş türünde döngüsel olarak kendine başvuruyor.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Zaman uyumsuz bir oluşturucudaki 'yield' işleneninin türü, geçerli bir promise olmalı veya çağrılabilir 'then' üyesi içermemelidir.", - "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Tür bu içeri aktarmadan kaynaklanıyor. Bir ad alanı stili içeri aktarma işlemi çağrılamaz ya da oluşturulamaz ve çalışma zamanında hataya neden olur. Bunun yerine varsayılan içeri aktarmayı kullanmayı veya içeri aktarmayı burada gerektirmeyi deneyin.", + "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038": "Tür bu içeri aktarmadan kaynaklanıyor. Ad alanı stili içeri aktarma işlemi çağrılamaz ya da oluşturulamaz ve çalışma zamanında hataya neden olur. Bunun yerine varsayılan içeri aktarmayı kullanabilir veya burada içeri aktarma gerektirebilirsiniz.", "Type_parameter_0_has_a_circular_constraint_2313": "'{0}' tür parametresi döngüsel bir kısıtlamaya sahip.", "Type_parameter_0_has_a_circular_default_2716": "'{0}' tür parametresi döngüsel bir varsayılana sahip.", "Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1_4008": "Dışarı aktarılan arabirimdeki çağrı imzasının '{0}' tür parametresi, '{1}' özel adına sahip veya bu adı kullanıyor.", diff --git a/lib/tsc.js b/lib/tsc.js index 361e447f84231..3d6d3efc24fcf 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -66,8 +66,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook }; var ts; (function (ts) { - ts.versionMajorMinor = "3.9"; - ts.version = "3.9.2"; + ts.versionMajorMinor = "4.0"; + ts.version = ts.versionMajorMinor + ".0-dev"; function tryGetNativeMap() { return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } @@ -4201,7 +4201,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -4886,6 +4886,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -5438,6 +5440,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -25325,7 +25329,7 @@ var ts; currentFlow.node = node; } } - currentReturnTarget = isIIFE || node.kind === 162 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 || (ts.isInJSFile && (node.kind === 244 || node.kind === 201)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -25345,7 +25349,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162) { + if (node.kind === 162 || (ts.isInJSFile && (node.kind === 244 || node.kind === 201))) { node.returnFlowNode = currentFlow; } } @@ -27212,7 +27216,7 @@ var ts; bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } function bindSpecialPropertyAssignment(node) { - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -27221,17 +27225,18 @@ var ts; if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, false, false); } @@ -27297,7 +27302,7 @@ var ts; : propertyAccess.parent.parent.kind === 290; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -28608,6 +28613,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -28971,6 +28977,7 @@ var ts; }; var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; var patternAmbientModules; var patternAmbientModuleAugmentations; @@ -29448,7 +29455,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { if (declaration.kind === 191) { var errorBindingElement = ts.getAncestor(usage, 191); if (errorBindingElement) { @@ -30332,8 +30339,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -32763,15 +32770,12 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -32791,7 +32795,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -32830,14 +32834,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature(undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125), undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125), node); } @@ -32853,9 +32849,6 @@ var ts; return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter(undefined, undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -34234,6 +34227,13 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { return trueType; } @@ -34242,6 +34242,50 @@ var ts; } return undefined; } + function isConstructorDeclaredProperty(symbol) { + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 && + (declaration.left.kind !== 195 || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, false); + if (container && (container.kind === 162 || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); if (container) { @@ -34252,51 +34296,57 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; + } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types; + type = getUnionType(sourceTypes, 2); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types; - type = getUnionType(sourceTypes, 2); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) { @@ -34438,19 +34488,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType; @@ -38531,6 +38568,9 @@ var ts; if (accessFlags & 4) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ? @@ -39699,7 +39739,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -39726,34 +39766,23 @@ var ts; } if (flags & 524288) { var objectFlags = type.objectFlags; - if (objectFlags & 16) { - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 | 16 | 32)) { + if (objectFlags & 4 && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152) || (flags & 1048576 && !(flags & 131068))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304) { return getIndexType(instantiateType(type.type, mapper)); @@ -40955,7 +40984,7 @@ var ts; } } if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4); inPropertyCheck = false; @@ -42295,6 +42324,11 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } function isPropertyInClassDerivedFrom(prop, baseClass) { return forEachProperty(prop, function (sp) { var sourceClass = getDeclaringClass(sp); @@ -43045,15 +43079,22 @@ var ts; return !!(objectFlags & 134217728); } var result = !!(type.flags & 63176704 || - objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || - objectFlags & (32 | 131072) || - type.flags & 3145728 && !(type.flags & 1024) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 && !isNonGenericTopLevelType(type) && (objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || + objectFlags & (32 | 131072)) || + type.flags & 3145728 && !(type.flags & 1024) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393) { type.objectFlags |= 67108864 | (result ? 134217728 : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 ? true : n.kind === 249 ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -43079,12 +43120,16 @@ var ts; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -44630,7 +44675,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576) { @@ -44676,7 +44721,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 || predicate.kind === 3)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) : predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -44858,14 +44903,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 ? declaredType : computedType; + if (!(type.flags & 1048576) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -44889,7 +44935,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); }); } return type; @@ -44942,10 +44988,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -45262,7 +45308,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536)) { type = getTypeWithFacts(type, 2097152); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -45299,7 +45345,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 : 262144); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); }); } return type; @@ -45741,6 +45787,9 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -47591,6 +47640,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -47663,7 +47715,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -47674,6 +47726,9 @@ var ts; prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } var assumeUninitialized = false; if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 104) { var declaration = prop && prop.valueDeclaration; @@ -50320,11 +50375,20 @@ var ts; } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 | 131072; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -50517,7 +50581,8 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 | 12288))) { + if (!(allTypesAssignableToKind(leftType, 132 | 296 | 12288) || + isTypeAssignableToKind(leftType, 4194304 | 262144))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 | 58982400)) { @@ -50865,6 +50930,12 @@ var ts; case 49: case 71: reportOperatorError(); + break; + case 42: + case 66: + if (languageVersion < 3) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -52636,7 +52707,7 @@ var ts; } var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -57530,9 +57601,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -59792,9 +59863,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -82856,11 +82929,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -82920,11 +82993,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -85752,8 +85825,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); diff --git a/lib/tsserver.js b/lib/tsserver.js index 2b6f035cc95ba..e9b97043b30d7 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -92,9 +92,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.9"; + ts.versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.2"; + ts.version = ts.versionMajorMinor + ".0-dev"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6711,7 +6711,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -7396,6 +7396,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -7948,6 +7950,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -14685,7 +14689,7 @@ var ts; } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -16562,11 +16566,9 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { - // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { - // eslint-disable-next-line setAccessor = member; } } @@ -31078,7 +31080,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -31099,7 +31101,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162 /* Constructor */) { + if (node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -33208,7 +33210,7 @@ var ts; } function bindSpecialPropertyAssignment(node) { // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -33221,13 +33223,15 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -33235,7 +33239,6 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -33307,7 +33310,7 @@ var ts; : propertyAccess.parent.parent.kind === 290 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -35007,6 +35010,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -35382,6 +35386,7 @@ var ts; /** Key is "/path/to/a.ts|/path/to/b.ts". */ var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; /** * List of every ambient module with a "*" wildcard. @@ -35907,7 +35912,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === 191 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) @@ -36996,8 +37001,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -39691,9 +39696,6 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39704,7 +39706,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39724,7 +39726,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39764,16 +39766,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature( - /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), - /*initializer*/ undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39801,9 +39793,6 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -41496,6 +41485,15 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -41509,6 +41507,56 @@ var ts; // No type specified and nothing can be inferred return undefined; } + function isConstructorDeclaredProperty(symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && + (declaration.left.kind !== 195 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === 162 /* Constructor */ || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -41520,52 +41568,60 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; // No types from any declarations :( + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes, 2 /* Subtype */); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { @@ -41720,20 +41776,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -46374,6 +46416,9 @@ var ts; if (accessFlags & 4 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? @@ -47677,7 +47722,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -47711,37 +47756,23 @@ var ts; } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; - if (objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32 /* Mapped */) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4 /* Reference */) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { + if (objectFlags & 4 /* Reference */ && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728 /* UnionOrIntersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152 /* Intersection */) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 /* Intersection */ ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -49143,7 +49174,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -50699,6 +50730,12 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } // Return true if some underlying source property is declared in a class that derives // from the given base class. function isPropertyInClassDerivedFrom(prop, baseClass) { @@ -51550,15 +51587,22 @@ var ts; return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } var result = !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 /* SourceFile */ ? true : n.kind === 249 /* ModuleDeclaration */ ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -51591,12 +51635,16 @@ var ts; * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -53331,7 +53379,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { @@ -53385,7 +53433,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -53614,14 +53662,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; + if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -53645,7 +53694,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; @@ -53698,10 +53747,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -54095,7 +54144,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -54135,7 +54184,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; @@ -54671,6 +54720,10 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -56928,6 +56981,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -57001,7 +57057,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -57015,6 +57071,9 @@ var ts; prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -60110,17 +60169,25 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } - // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -60330,7 +60397,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { + if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -60715,6 +60783,12 @@ var ts; case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); + break; + case 42 /* AsteriskAsteriskToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ES2016 */) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -62837,7 +62911,7 @@ var ts; if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -68487,9 +68561,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -70874,9 +70948,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -100680,11 +100756,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -100757,11 +100833,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -104073,8 +104149,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -120238,6 +120314,8 @@ var ts; case 251 /* CaseBlock */: case 173 /* TypeLiteral */: return spanForNode(n); + case 175 /* TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); case 277 /* CaseClause */: case 278 /* DefaultClause */: return spanForNodeArray(n.statements); @@ -120255,6 +120333,8 @@ var ts; case 211 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); + case 190 /* ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); @@ -128215,83 +128295,151 @@ var ts; var memberElements = []; // all instance members are stored in the "member" array of symbol if (symbol.members) { - symbol.members.forEach(function (member) { + symbol.members.forEach(function (member, key) { + if (key === "constructor") { + // fn.prototype.constructor = fn + changes.delete(sourceFile, member.valueDeclaration.parent); + return; + } var memberElement = createClassElement(member, /*modifiers*/ undefined); if (memberElement) { - memberElements.push(memberElement); + memberElements.push.apply(memberElements, memberElement); } }); } // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); + if (member.name === "prototype") { + var firstDeclaration = member.declarations[0]; + // only one "x.prototype = { ... }" will pass + if (member.declarations.length === 1 && + ts.isPropertyAccessExpression(firstDeclaration) && + ts.isBinaryExpression(firstDeclaration.parent) && + firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { + var prototypes = firstDeclaration.parent.right; + var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } + } + } + else { + var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } } }); } return memberElements; function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); + // Right now the only thing we can convert are function expressions, get/set accessors and methods + // other values like normal value fields ({a: 1}) shouldn't get transformed. + // We can update this once ES public class properties are available. + if (ts.isPropertyAccessExpression(_target)) { + if (isConstructorAssignment(_target)) + return true; + return ts.isFunctionLike(source); + } + else { + return ts.every(_target.properties, function (property) { + // a() {} + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) + return true; + // a: function() {} + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer) && !!property.name) + return true; + // x.prototype.constructor = fn + if (isConstructorAssignment(property)) + return true; + return false; + }); + } } function createClassElement(symbol, modifiers) { // Right now the only thing we can convert are function expressions, which are marked as methods - if (!(symbol.flags & 8192 /* Method */)) { - return; + // or { x: y } type prototype assignments, which are marked as ObjectLiteral + var members = []; + if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + return members; } var memberDeclaration = symbol.valueDeclaration; var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var assignmentExpr = assignmentBinaryExpression.right; + if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) { + return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 226 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); - } - switch (assignmentBinaryExpression.right.kind) { - case 201 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - case 202 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 223 /* Block */) { - bodyBlock = arrowFunctionBody; - } - // case 2: () => [1,2,3] - else { - bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); - } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJS(sourceFile)) { - return; - } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); - return prop; + if (!assignmentExpr) { + members.push(ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined)); + return members; + } + // f.x = expr + if (ts.isPropertyAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) { + return createFunctionLikeExpressionMember(members, assignmentExpr, memberDeclaration.name); + } + // f.prototype = { ... } + else if (ts.isObjectLiteralExpression(assignmentExpr)) { + return ts.flatMap(assignmentExpr.properties, function (property) { + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) { + // MethodDeclaration and AccessorDeclaration can appear in a class directly + return members.concat(property); + } + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) { + return createFunctionLikeExpressionMember(members, property.initializer, property.name); + } + // Drop constructor assignments + if (isConstructorAssignment(property)) + return members; + return []; + }); + } + else { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJS(sourceFile)) + return members; + if (!ts.isPropertyAccessExpression(memberDeclaration)) + return members; + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); + ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); + members.push(prop); + return members; + } + function createFunctionLikeExpressionMember(members, expression, name) { + if (ts.isFunctionExpression(expression)) + return createFunctionExpressionMember(members, expression, name); + else + return createArrowFunctionExpressionMember(members, expression, name); + } + function createFunctionExpressionMember(members, functionExpression, name) { + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); + } + function createArrowFunctionExpressionMember(members, arrowFunction, name) { + var arrowFunctionBody = arrowFunction.body; + var bodyBlock; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 223 /* Block */) { + bodyBlock = arrowFunctionBody; + } + // case 2: () => [1,2,3] + else { + bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); } } } @@ -128328,6 +128476,13 @@ var ts; function getModifierKindFromSource(source, kind) { return ts.filter(source.modifiers, function (modifier) { return modifier.kind === kind; }); } + function isConstructorAssignment(x) { + if (!x.name) + return false; + if (ts.isIdentifier(x.name) && x.name.text === "constructor") + return true; + return false; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -133035,6 +133190,59 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixReturnTypeInAsyncFunction"; + var errorCodes = [ + ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, span = context.span; + var checker = program.getTypeChecker(); + var info = getInfo(sourceFile, program.getTypeChecker(), span.start); + if (!info) { + return undefined; + } + var returnTypeNode = info.returnTypeNode, returnType = info.returnType, promisedTypeNode = info.promisedTypeNode, promisedType = info.promisedType; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, returnTypeNode, promisedTypeNode); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Replace_0_with_Promise_1, + checker.typeToString(returnType), checker.typeToString(promisedType)], fixId, ts.Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, context.program.getTypeChecker(), diag.start); + if (info) { + doChange(changes, diag.file, info.returnTypeNode, info.promisedTypeNode); + } + }); } + }); + function getInfo(sourceFile, checker, pos) { + if (ts.isInJSFile(sourceFile)) { + return undefined; + } + var token = ts.getTokenAtPosition(sourceFile, pos); + var func = ts.findAncestor(token, ts.isFunctionLikeDeclaration); + var returnTypeNode = func === null || func === void 0 ? void 0 : func.type; + if (!returnTypeNode) { + return undefined; + } + var returnType = checker.getTypeFromTypeNode(returnTypeNode); + var promisedType = checker.getAwaitedType(returnType) || checker.getVoidType(); + var promisedTypeNode = checker.typeToTypeNode(promisedType, /*enclosingDeclaration*/ returnTypeNode, /*flags*/ undefined); + if (promisedTypeNode) { + return { returnTypeNode: returnTypeNode, returnType: returnType, promisedTypeNode: promisedTypeNode, promisedType: promisedType }; + } + } + function doChange(changes, sourceFile, returnTypeNode, promisedTypeNode) { + changes.replaceNode(sourceFile, returnTypeNode, ts.createTypeReferenceNode("Promise", [promisedTypeNode])); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -136714,7 +136922,6 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: - case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index e45bd38e2de1a..c9c2c066f8361 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.9"; + const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -2040,23 +2040,23 @@ declare namespace ts { getNonNullableType(type: Type): Type; getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; + typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): (SignatureDeclaration & { typeArguments?: NodeArray; }) | undefined; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; + symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Expression | undefined; + symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): NodeArray | undefined; + symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): ParameterDeclaration | undefined; + symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeParameterDeclaration | undefined; + typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol | undefined; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -4960,6 +4960,7 @@ declare namespace ts.server { interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 60e8447a1cd8d..41618feb3bab0 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -242,9 +242,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.9"; + ts.versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.2"; + ts.version = ts.versionMajorMinor + ".0-dev"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6861,7 +6861,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -7546,6 +7546,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -8098,6 +8100,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -14835,7 +14839,7 @@ var ts; } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -16712,11 +16716,9 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { - // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { - // eslint-disable-next-line setAccessor = member; } } @@ -31228,7 +31230,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -31249,7 +31251,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162 /* Constructor */) { + if (node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -33358,7 +33360,7 @@ var ts; } function bindSpecialPropertyAssignment(node) { // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -33371,13 +33373,15 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -33385,7 +33389,6 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -33457,7 +33460,7 @@ var ts; : propertyAccess.parent.parent.kind === 290 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -35157,6 +35160,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -35532,6 +35536,7 @@ var ts; /** Key is "/path/to/a.ts|/path/to/b.ts". */ var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; /** * List of every ambient module with a "*" wildcard. @@ -36057,7 +36062,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === 191 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) @@ -37146,8 +37151,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -39841,9 +39846,6 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39854,7 +39856,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39874,7 +39876,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39914,16 +39916,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature( - /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), - /*initializer*/ undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39951,9 +39943,6 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -41646,6 +41635,15 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -41659,6 +41657,56 @@ var ts; // No type specified and nothing can be inferred return undefined; } + function isConstructorDeclaredProperty(symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && + (declaration.left.kind !== 195 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === 162 /* Constructor */ || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -41670,52 +41718,60 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; // No types from any declarations :( + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes, 2 /* Subtype */); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { @@ -41870,20 +41926,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -46524,6 +46566,9 @@ var ts; if (accessFlags & 4 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? @@ -47827,7 +47872,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -47861,37 +47906,23 @@ var ts; } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; - if (objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32 /* Mapped */) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4 /* Reference */) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { + if (objectFlags & 4 /* Reference */ && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728 /* UnionOrIntersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152 /* Intersection */) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 /* Intersection */ ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -49293,7 +49324,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -50849,6 +50880,12 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } // Return true if some underlying source property is declared in a class that derives // from the given base class. function isPropertyInClassDerivedFrom(prop, baseClass) { @@ -51700,15 +51737,22 @@ var ts; return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } var result = !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 /* SourceFile */ ? true : n.kind === 249 /* ModuleDeclaration */ ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -51741,12 +51785,16 @@ var ts; * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -53481,7 +53529,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { @@ -53535,7 +53583,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -53764,14 +53812,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; + if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -53795,7 +53844,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; @@ -53848,10 +53897,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -54245,7 +54294,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -54285,7 +54334,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; @@ -54821,6 +54870,10 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -57078,6 +57131,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -57151,7 +57207,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -57165,6 +57221,9 @@ var ts; prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -60260,17 +60319,25 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } - // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -60480,7 +60547,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { + if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -60865,6 +60933,12 @@ var ts; case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); + break; + case 42 /* AsteriskAsteriskToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ES2016 */) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -62987,7 +63061,7 @@ var ts; if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -68637,9 +68711,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -71024,9 +71098,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -100830,11 +100906,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -100907,11 +100983,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -104223,8 +104299,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -120761,6 +120837,8 @@ var ts; case 251 /* CaseBlock */: case 173 /* TypeLiteral */: return spanForNode(n); + case 175 /* TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); case 277 /* CaseClause */: case 278 /* DefaultClause */: return spanForNodeArray(n.statements); @@ -120778,6 +120856,8 @@ var ts; case 211 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); + case 190 /* ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); @@ -128738,83 +128818,151 @@ var ts; var memberElements = []; // all instance members are stored in the "member" array of symbol if (symbol.members) { - symbol.members.forEach(function (member) { + symbol.members.forEach(function (member, key) { + if (key === "constructor") { + // fn.prototype.constructor = fn + changes.delete(sourceFile, member.valueDeclaration.parent); + return; + } var memberElement = createClassElement(member, /*modifiers*/ undefined); if (memberElement) { - memberElements.push(memberElement); + memberElements.push.apply(memberElements, memberElement); } }); } // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); + if (member.name === "prototype") { + var firstDeclaration = member.declarations[0]; + // only one "x.prototype = { ... }" will pass + if (member.declarations.length === 1 && + ts.isPropertyAccessExpression(firstDeclaration) && + ts.isBinaryExpression(firstDeclaration.parent) && + firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { + var prototypes = firstDeclaration.parent.right; + var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } + } + } + else { + var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } } }); } return memberElements; function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); + // Right now the only thing we can convert are function expressions, get/set accessors and methods + // other values like normal value fields ({a: 1}) shouldn't get transformed. + // We can update this once ES public class properties are available. + if (ts.isPropertyAccessExpression(_target)) { + if (isConstructorAssignment(_target)) + return true; + return ts.isFunctionLike(source); + } + else { + return ts.every(_target.properties, function (property) { + // a() {} + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) + return true; + // a: function() {} + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer) && !!property.name) + return true; + // x.prototype.constructor = fn + if (isConstructorAssignment(property)) + return true; + return false; + }); + } } function createClassElement(symbol, modifiers) { // Right now the only thing we can convert are function expressions, which are marked as methods - if (!(symbol.flags & 8192 /* Method */)) { - return; + // or { x: y } type prototype assignments, which are marked as ObjectLiteral + var members = []; + if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + return members; } var memberDeclaration = symbol.valueDeclaration; var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var assignmentExpr = assignmentBinaryExpression.right; + if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) { + return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 226 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); - } - switch (assignmentBinaryExpression.right.kind) { - case 201 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - case 202 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 223 /* Block */) { - bodyBlock = arrowFunctionBody; - } - // case 2: () => [1,2,3] - else { - bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); - } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJS(sourceFile)) { - return; - } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); - return prop; + if (!assignmentExpr) { + members.push(ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined)); + return members; + } + // f.x = expr + if (ts.isPropertyAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) { + return createFunctionLikeExpressionMember(members, assignmentExpr, memberDeclaration.name); + } + // f.prototype = { ... } + else if (ts.isObjectLiteralExpression(assignmentExpr)) { + return ts.flatMap(assignmentExpr.properties, function (property) { + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) { + // MethodDeclaration and AccessorDeclaration can appear in a class directly + return members.concat(property); + } + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) { + return createFunctionLikeExpressionMember(members, property.initializer, property.name); + } + // Drop constructor assignments + if (isConstructorAssignment(property)) + return members; + return []; + }); + } + else { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJS(sourceFile)) + return members; + if (!ts.isPropertyAccessExpression(memberDeclaration)) + return members; + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); + ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); + members.push(prop); + return members; + } + function createFunctionLikeExpressionMember(members, expression, name) { + if (ts.isFunctionExpression(expression)) + return createFunctionExpressionMember(members, expression, name); + else + return createArrowFunctionExpressionMember(members, expression, name); + } + function createFunctionExpressionMember(members, functionExpression, name) { + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); + } + function createArrowFunctionExpressionMember(members, arrowFunction, name) { + var arrowFunctionBody = arrowFunction.body; + var bodyBlock; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 223 /* Block */) { + bodyBlock = arrowFunctionBody; + } + // case 2: () => [1,2,3] + else { + bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); } } } @@ -128851,6 +128999,13 @@ var ts; function getModifierKindFromSource(source, kind) { return ts.filter(source.modifiers, function (modifier) { return modifier.kind === kind; }); } + function isConstructorAssignment(x) { + if (!x.name) + return false; + if (ts.isIdentifier(x.name) && x.name.text === "constructor") + return true; + return false; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -133558,6 +133713,59 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixReturnTypeInAsyncFunction"; + var errorCodes = [ + ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, span = context.span; + var checker = program.getTypeChecker(); + var info = getInfo(sourceFile, program.getTypeChecker(), span.start); + if (!info) { + return undefined; + } + var returnTypeNode = info.returnTypeNode, returnType = info.returnType, promisedTypeNode = info.promisedTypeNode, promisedType = info.promisedType; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, returnTypeNode, promisedTypeNode); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Replace_0_with_Promise_1, + checker.typeToString(returnType), checker.typeToString(promisedType)], fixId, ts.Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, context.program.getTypeChecker(), diag.start); + if (info) { + doChange(changes, diag.file, info.returnTypeNode, info.promisedTypeNode); + } + }); } + }); + function getInfo(sourceFile, checker, pos) { + if (ts.isInJSFile(sourceFile)) { + return undefined; + } + var token = ts.getTokenAtPosition(sourceFile, pos); + var func = ts.findAncestor(token, ts.isFunctionLikeDeclaration); + var returnTypeNode = func === null || func === void 0 ? void 0 : func.type; + if (!returnTypeNode) { + return undefined; + } + var returnType = checker.getTypeFromTypeNode(returnTypeNode); + var promisedType = checker.getAwaitedType(returnType) || checker.getVoidType(); + var promisedTypeNode = checker.typeToTypeNode(promisedType, /*enclosingDeclaration*/ returnTypeNode, /*flags*/ undefined); + if (promisedTypeNode) { + return { returnTypeNode: returnTypeNode, returnType: returnType, promisedTypeNode: promisedTypeNode, promisedType: promisedType }; + } + } + function doChange(changes, sourceFile, returnTypeNode, promisedTypeNode) { + changes.replaceNode(sourceFile, returnTypeNode, ts.createTypeReferenceNode("Promise", [promisedTypeNode])); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -137237,7 +137445,6 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: - case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 62e8560ae488d..e1a34cf708250 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.9"; + const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -2040,23 +2040,23 @@ declare namespace ts { getNonNullableType(type: Type): Type; getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; + typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): (SignatureDeclaration & { typeArguments?: NodeArray; }) | undefined; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; + symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Expression | undefined; + symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): NodeArray | undefined; + symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): ParameterDeclaration | undefined; + symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeParameterDeclaration | undefined; + typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol | undefined; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -4960,6 +4960,7 @@ declare namespace ts.server { interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; diff --git a/lib/typescript.js b/lib/typescript.js index 90202c1c5b1e7..63718c68e7134 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -242,9 +242,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.9"; + ts.versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.2"; + ts.version = ts.versionMajorMinor + ".0-dev"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6861,7 +6861,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -7546,6 +7546,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -8098,6 +8100,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -14835,7 +14839,7 @@ var ts; } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -16712,11 +16716,9 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { - // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { - // eslint-disable-next-line setAccessor = member; } } @@ -31228,7 +31230,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -31249,7 +31251,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162 /* Constructor */) { + if (node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -33358,7 +33360,7 @@ var ts; } function bindSpecialPropertyAssignment(node) { // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -33371,13 +33373,15 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -33385,7 +33389,6 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -33457,7 +33460,7 @@ var ts; : propertyAccess.parent.parent.kind === 290 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -35157,6 +35160,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -35532,6 +35536,7 @@ var ts; /** Key is "/path/to/a.ts|/path/to/b.ts". */ var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; /** * List of every ambient module with a "*" wildcard. @@ -36057,7 +36062,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === 191 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) @@ -37146,8 +37151,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -39841,9 +39846,6 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39854,7 +39856,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39874,7 +39876,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39914,16 +39916,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature( - /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), - /*initializer*/ undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39951,9 +39943,6 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -41646,6 +41635,15 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -41659,6 +41657,56 @@ var ts; // No type specified and nothing can be inferred return undefined; } + function isConstructorDeclaredProperty(symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && + (declaration.left.kind !== 195 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === 162 /* Constructor */ || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -41670,52 +41718,60 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; // No types from any declarations :( + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } + } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes, 2 /* Subtype */); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { @@ -41870,20 +41926,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -46524,6 +46566,9 @@ var ts; if (accessFlags & 4 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? @@ -47827,7 +47872,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -47861,37 +47906,23 @@ var ts; } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; - if (objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32 /* Mapped */) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4 /* Reference */) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { + if (objectFlags & 4 /* Reference */ && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728 /* UnionOrIntersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152 /* Intersection */) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 /* Intersection */ ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -49293,7 +49324,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -50849,6 +50880,12 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } // Return true if some underlying source property is declared in a class that derives // from the given base class. function isPropertyInClassDerivedFrom(prop, baseClass) { @@ -51700,15 +51737,22 @@ var ts; return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } var result = !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 /* SourceFile */ ? true : n.kind === 249 /* ModuleDeclaration */ ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -51741,12 +51785,16 @@ var ts; * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -53481,7 +53529,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { @@ -53535,7 +53583,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -53764,14 +53812,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; + if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -53795,7 +53844,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; @@ -53848,10 +53897,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -54245,7 +54294,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -54285,7 +54334,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; @@ -54821,6 +54870,10 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -57078,6 +57131,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -57151,7 +57207,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -57165,6 +57221,9 @@ var ts; prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -60260,17 +60319,25 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } - // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -60480,7 +60547,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { + if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -60865,6 +60933,12 @@ var ts; case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); + break; + case 42 /* AsteriskAsteriskToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ES2016 */) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -62987,7 +63061,7 @@ var ts; if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -68637,9 +68711,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -71024,9 +71098,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -100830,11 +100906,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -100907,11 +100983,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -104223,8 +104299,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -120761,6 +120837,8 @@ var ts; case 251 /* CaseBlock */: case 173 /* TypeLiteral */: return spanForNode(n); + case 175 /* TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); case 277 /* CaseClause */: case 278 /* DefaultClause */: return spanForNodeArray(n.statements); @@ -120778,6 +120856,8 @@ var ts; case 211 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); + case 190 /* ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); @@ -128738,83 +128818,151 @@ var ts; var memberElements = []; // all instance members are stored in the "member" array of symbol if (symbol.members) { - symbol.members.forEach(function (member) { + symbol.members.forEach(function (member, key) { + if (key === "constructor") { + // fn.prototype.constructor = fn + changes.delete(sourceFile, member.valueDeclaration.parent); + return; + } var memberElement = createClassElement(member, /*modifiers*/ undefined); if (memberElement) { - memberElements.push(memberElement); + memberElements.push.apply(memberElements, memberElement); } }); } // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); + if (member.name === "prototype") { + var firstDeclaration = member.declarations[0]; + // only one "x.prototype = { ... }" will pass + if (member.declarations.length === 1 && + ts.isPropertyAccessExpression(firstDeclaration) && + ts.isBinaryExpression(firstDeclaration.parent) && + firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { + var prototypes = firstDeclaration.parent.right; + var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } + } + } + else { + var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } } }); } return memberElements; function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); + // Right now the only thing we can convert are function expressions, get/set accessors and methods + // other values like normal value fields ({a: 1}) shouldn't get transformed. + // We can update this once ES public class properties are available. + if (ts.isPropertyAccessExpression(_target)) { + if (isConstructorAssignment(_target)) + return true; + return ts.isFunctionLike(source); + } + else { + return ts.every(_target.properties, function (property) { + // a() {} + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) + return true; + // a: function() {} + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer) && !!property.name) + return true; + // x.prototype.constructor = fn + if (isConstructorAssignment(property)) + return true; + return false; + }); + } } function createClassElement(symbol, modifiers) { // Right now the only thing we can convert are function expressions, which are marked as methods - if (!(symbol.flags & 8192 /* Method */)) { - return; + // or { x: y } type prototype assignments, which are marked as ObjectLiteral + var members = []; + if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + return members; } var memberDeclaration = symbol.valueDeclaration; var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var assignmentExpr = assignmentBinaryExpression.right; + if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) { + return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 226 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); - } - switch (assignmentBinaryExpression.right.kind) { - case 201 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - case 202 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 223 /* Block */) { - bodyBlock = arrowFunctionBody; + if (!assignmentExpr) { + members.push(ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined)); + return members; + } + // f.x = expr + if (ts.isPropertyAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) { + return createFunctionLikeExpressionMember(members, assignmentExpr, memberDeclaration.name); + } + // f.prototype = { ... } + else if (ts.isObjectLiteralExpression(assignmentExpr)) { + return ts.flatMap(assignmentExpr.properties, function (property) { + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) { + // MethodDeclaration and AccessorDeclaration can appear in a class directly + return members.concat(property); } - // case 2: () => [1,2,3] - else { - bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); - } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJS(sourceFile)) { - return; + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) { + return createFunctionLikeExpressionMember(members, property.initializer, property.name); } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); - return prop; + // Drop constructor assignments + if (isConstructorAssignment(property)) + return members; + return []; + }); + } + else { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJS(sourceFile)) + return members; + if (!ts.isPropertyAccessExpression(memberDeclaration)) + return members; + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); + ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); + members.push(prop); + return members; + } + function createFunctionLikeExpressionMember(members, expression, name) { + if (ts.isFunctionExpression(expression)) + return createFunctionExpressionMember(members, expression, name); + else + return createArrowFunctionExpressionMember(members, expression, name); + } + function createFunctionExpressionMember(members, functionExpression, name) { + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); + } + function createArrowFunctionExpressionMember(members, arrowFunction, name) { + var arrowFunctionBody = arrowFunction.body; + var bodyBlock; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 223 /* Block */) { + bodyBlock = arrowFunctionBody; + } + // case 2: () => [1,2,3] + else { + bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); } } } @@ -128851,6 +128999,13 @@ var ts; function getModifierKindFromSource(source, kind) { return ts.filter(source.modifiers, function (modifier) { return modifier.kind === kind; }); } + function isConstructorAssignment(x) { + if (!x.name) + return false; + if (ts.isIdentifier(x.name) && x.name.text === "constructor") + return true; + return false; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -133558,6 +133713,59 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixReturnTypeInAsyncFunction"; + var errorCodes = [ + ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, span = context.span; + var checker = program.getTypeChecker(); + var info = getInfo(sourceFile, program.getTypeChecker(), span.start); + if (!info) { + return undefined; + } + var returnTypeNode = info.returnTypeNode, returnType = info.returnType, promisedTypeNode = info.promisedTypeNode, promisedType = info.promisedType; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, returnTypeNode, promisedTypeNode); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Replace_0_with_Promise_1, + checker.typeToString(returnType), checker.typeToString(promisedType)], fixId, ts.Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, context.program.getTypeChecker(), diag.start); + if (info) { + doChange(changes, diag.file, info.returnTypeNode, info.promisedTypeNode); + } + }); } + }); + function getInfo(sourceFile, checker, pos) { + if (ts.isInJSFile(sourceFile)) { + return undefined; + } + var token = ts.getTokenAtPosition(sourceFile, pos); + var func = ts.findAncestor(token, ts.isFunctionLikeDeclaration); + var returnTypeNode = func === null || func === void 0 ? void 0 : func.type; + if (!returnTypeNode) { + return undefined; + } + var returnType = checker.getTypeFromTypeNode(returnTypeNode); + var promisedType = checker.getAwaitedType(returnType) || checker.getVoidType(); + var promisedTypeNode = checker.typeToTypeNode(promisedType, /*enclosingDeclaration*/ returnTypeNode, /*flags*/ undefined); + if (promisedTypeNode) { + return { returnTypeNode: returnTypeNode, returnType: returnType, promisedTypeNode: promisedTypeNode, promisedType: promisedType }; + } + } + function doChange(changes, sourceFile, returnTypeNode, promisedTypeNode) { + changes.replaceNode(sourceFile, returnTypeNode, ts.createTypeReferenceNode("Promise", [promisedTypeNode])); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -137237,7 +137445,6 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: - case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 6973aa20b7a2c..39ea8a4089d9b 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.9"; + const versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -2040,23 +2040,23 @@ declare namespace ts { getNonNullableType(type: Type): Type; getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; + typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): (SignatureDeclaration & { typeArguments?: NodeArray; }) | undefined; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; + symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): Expression | undefined; + symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): NodeArray | undefined; + symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray | undefined; /** Note that the resulting nodes cannot be checked. */ - symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): ParameterDeclaration | undefined; + symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; /** Note that the resulting nodes cannot be checked. */ - typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeParameterDeclaration | undefined; + typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol | undefined; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -4960,6 +4960,7 @@ declare namespace ts.server { interface InitializationFailedResponse extends TypingInstallerResponse { readonly kind: EventInitializationFailed; readonly message: string; + readonly stack?: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index d78fb9eda99d6..f666b85f161dc 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -242,9 +242,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.9"; + ts.versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.2"; + ts.version = ts.versionMajorMinor + ".0-dev"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6861,7 +6861,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -7546,6 +7546,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -8098,6 +8100,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -14835,7 +14839,7 @@ var ts; } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -16712,11 +16716,9 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { - // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { - // eslint-disable-next-line setAccessor = member; } } @@ -31228,7 +31230,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -31249,7 +31251,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162 /* Constructor */) { + if (node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -33358,7 +33360,7 @@ var ts; } function bindSpecialPropertyAssignment(node) { // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -33371,13 +33373,15 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -33385,7 +33389,6 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -33457,7 +33460,7 @@ var ts; : propertyAccess.parent.parent.kind === 290 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -35157,6 +35160,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -35532,6 +35536,7 @@ var ts; /** Key is "/path/to/a.ts|/path/to/b.ts". */ var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; /** * List of every ambient module with a "*" wildcard. @@ -36057,7 +36062,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === 191 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) @@ -37146,8 +37151,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -39841,9 +39846,6 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39854,7 +39856,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39874,7 +39876,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39914,16 +39916,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature( - /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), - /*initializer*/ undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39951,9 +39943,6 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -41646,6 +41635,15 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -41659,6 +41657,56 @@ var ts; // No type specified and nothing can be inferred return undefined; } + function isConstructorDeclaredProperty(symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && + (declaration.left.kind !== 195 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === 162 /* Constructor */ || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -41670,52 +41718,60 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; // No types from any declarations :( + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } + } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes, 2 /* Subtype */); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { @@ -41870,20 +41926,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -46524,6 +46566,9 @@ var ts; if (accessFlags & 4 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? @@ -47827,7 +47872,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -47861,37 +47906,23 @@ var ts; } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; - if (objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32 /* Mapped */) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4 /* Reference */) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { + if (objectFlags & 4 /* Reference */ && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728 /* UnionOrIntersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152 /* Intersection */) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 /* Intersection */ ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -49293,7 +49324,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -50849,6 +50880,12 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } // Return true if some underlying source property is declared in a class that derives // from the given base class. function isPropertyInClassDerivedFrom(prop, baseClass) { @@ -51700,15 +51737,22 @@ var ts; return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } var result = !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 /* SourceFile */ ? true : n.kind === 249 /* ModuleDeclaration */ ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -51741,12 +51785,16 @@ var ts; * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -53481,7 +53529,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { @@ -53535,7 +53583,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -53764,14 +53812,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; + if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -53795,7 +53844,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; @@ -53848,10 +53897,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -54245,7 +54294,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -54285,7 +54334,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; @@ -54821,6 +54870,10 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -57078,6 +57131,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -57151,7 +57207,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -57165,6 +57221,9 @@ var ts; prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -60260,17 +60319,25 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } - // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -60480,7 +60547,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { + if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -60865,6 +60933,12 @@ var ts; case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); + break; + case 42 /* AsteriskAsteriskToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ES2016 */) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -62987,7 +63061,7 @@ var ts; if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -68637,9 +68711,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -71024,9 +71098,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -100830,11 +100906,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -100907,11 +100983,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -104223,8 +104299,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -120761,6 +120837,8 @@ var ts; case 251 /* CaseBlock */: case 173 /* TypeLiteral */: return spanForNode(n); + case 175 /* TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); case 277 /* CaseClause */: case 278 /* DefaultClause */: return spanForNodeArray(n.statements); @@ -120778,6 +120856,8 @@ var ts; case 211 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); + case 190 /* ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); @@ -128738,83 +128818,151 @@ var ts; var memberElements = []; // all instance members are stored in the "member" array of symbol if (symbol.members) { - symbol.members.forEach(function (member) { + symbol.members.forEach(function (member, key) { + if (key === "constructor") { + // fn.prototype.constructor = fn + changes.delete(sourceFile, member.valueDeclaration.parent); + return; + } var memberElement = createClassElement(member, /*modifiers*/ undefined); if (memberElement) { - memberElements.push(memberElement); + memberElements.push.apply(memberElements, memberElement); } }); } // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); - if (memberElement) { - memberElements.push(memberElement); + if (member.name === "prototype") { + var firstDeclaration = member.declarations[0]; + // only one "x.prototype = { ... }" will pass + if (member.declarations.length === 1 && + ts.isPropertyAccessExpression(firstDeclaration) && + ts.isBinaryExpression(firstDeclaration.parent) && + firstDeclaration.parent.operatorToken.kind === 62 /* EqualsToken */ && + ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { + var prototypes = firstDeclaration.parent.right; + var memberElement = createClassElement(prototypes.symbol, /** modifiers */ undefined); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } + } + } + else { + var memberElement = createClassElement(member, [ts.createToken(120 /* StaticKeyword */)]); + if (memberElement) { + memberElements.push.apply(memberElements, memberElement); + } } }); } return memberElements; function shouldConvertDeclaration(_target, source) { - // Right now the only thing we can convert are function expressions - other values shouldn't get - // transformed. We can update this once ES public class properties are available. - return ts.isFunctionLike(source); + // Right now the only thing we can convert are function expressions, get/set accessors and methods + // other values like normal value fields ({a: 1}) shouldn't get transformed. + // We can update this once ES public class properties are available. + if (ts.isPropertyAccessExpression(_target)) { + if (isConstructorAssignment(_target)) + return true; + return ts.isFunctionLike(source); + } + else { + return ts.every(_target.properties, function (property) { + // a() {} + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) + return true; + // a: function() {} + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer) && !!property.name) + return true; + // x.prototype.constructor = fn + if (isConstructorAssignment(property)) + return true; + return false; + }); + } } function createClassElement(symbol, modifiers) { // Right now the only thing we can convert are function expressions, which are marked as methods - if (!(symbol.flags & 8192 /* Method */)) { - return; + // or { x: y } type prototype assignments, which are marked as ObjectLiteral + var members = []; + if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + return members; } var memberDeclaration = symbol.valueDeclaration; var assignmentBinaryExpression = memberDeclaration.parent; - if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { - return; + var assignmentExpr = assignmentBinaryExpression.right; + if (!shouldConvertDeclaration(memberDeclaration, assignmentExpr)) { + return members; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 226 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); - if (!assignmentBinaryExpression.right) { - return ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, - /*type*/ undefined, /*initializer*/ undefined); - } - switch (assignmentBinaryExpression.right.kind) { - case 201 /* FunctionExpression */: { - var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - case 202 /* ArrowFunction */: { - var arrowFunction = assignmentBinaryExpression.right; - var arrowFunctionBody = arrowFunction.body; - var bodyBlock = void 0; - // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 223 /* Block */) { - bodyBlock = arrowFunctionBody; + if (!assignmentExpr) { + members.push(ts.createProperty([], modifiers, symbol.name, /*questionToken*/ undefined, + /*type*/ undefined, /*initializer*/ undefined)); + return members; + } + // f.x = expr + if (ts.isPropertyAccessExpression(memberDeclaration) && (ts.isFunctionExpression(assignmentExpr) || ts.isArrowFunction(assignmentExpr))) { + return createFunctionLikeExpressionMember(members, assignmentExpr, memberDeclaration.name); + } + // f.prototype = { ... } + else if (ts.isObjectLiteralExpression(assignmentExpr)) { + return ts.flatMap(assignmentExpr.properties, function (property) { + if (ts.isMethodDeclaration(property) || ts.isGetOrSetAccessorDeclaration(property)) { + // MethodDeclaration and AccessorDeclaration can appear in a class directly + return members.concat(property); } - // case 2: () => [1,2,3] - else { - bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); - } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); - var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, - /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); - ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); - return method; - } - default: { - // Don't try to declare members in JavaScript files - if (ts.isSourceFileJS(sourceFile)) { - return; + if (ts.isPropertyAssignment(property) && ts.isFunctionExpression(property.initializer)) { + return createFunctionLikeExpressionMember(members, property.initializer, property.name); } - var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, - /*type*/ undefined, assignmentBinaryExpression.right); - ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); - return prop; + // Drop constructor assignments + if (isConstructorAssignment(property)) + return members; + return []; + }); + } + else { + // Don't try to declare members in JavaScript files + if (ts.isSourceFileJS(sourceFile)) + return members; + if (!ts.isPropertyAccessExpression(memberDeclaration)) + return members; + var prop = ts.createProperty(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); + ts.copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); + members.push(prop); + return members; + } + function createFunctionLikeExpressionMember(members, expression, name) { + if (ts.isFunctionExpression(expression)) + return createFunctionExpressionMember(members, expression, name); + else + return createArrowFunctionExpressionMember(members, expression, name); + } + function createFunctionExpressionMember(members, functionExpression, name) { + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); + } + function createArrowFunctionExpressionMember(members, arrowFunction, name) { + var arrowFunctionBody = arrowFunction.body; + var bodyBlock; + // case 1: () => { return [1,2,3] } + if (arrowFunctionBody.kind === 223 /* Block */) { + bodyBlock = arrowFunctionBody; + } + // case 2: () => [1,2,3] + else { + bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 126 /* AsyncKeyword */)); + var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); + ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); + return members.concat(method); } } } @@ -128851,6 +128999,13 @@ var ts; function getModifierKindFromSource(source, kind) { return ts.filter(source.modifiers, function (modifier) { return modifier.kind === kind; }); } + function isConstructorAssignment(x) { + if (!x.name) + return false; + if (ts.isIdentifier(x.name) && x.name.text === "constructor") + return true; + return false; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -133558,6 +133713,59 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixReturnTypeInAsyncFunction"; + var errorCodes = [ + ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, span = context.span; + var checker = program.getTypeChecker(); + var info = getInfo(sourceFile, program.getTypeChecker(), span.start); + if (!info) { + return undefined; + } + var returnTypeNode = info.returnTypeNode, returnType = info.returnType, promisedTypeNode = info.promisedTypeNode, promisedType = info.promisedType; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, returnTypeNode, promisedTypeNode); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Replace_0_with_Promise_1, + checker.typeToString(returnType), checker.typeToString(promisedType)], fixId, ts.Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, context.program.getTypeChecker(), diag.start); + if (info) { + doChange(changes, diag.file, info.returnTypeNode, info.promisedTypeNode); + } + }); } + }); + function getInfo(sourceFile, checker, pos) { + if (ts.isInJSFile(sourceFile)) { + return undefined; + } + var token = ts.getTokenAtPosition(sourceFile, pos); + var func = ts.findAncestor(token, ts.isFunctionLikeDeclaration); + var returnTypeNode = func === null || func === void 0 ? void 0 : func.type; + if (!returnTypeNode) { + return undefined; + } + var returnType = checker.getTypeFromTypeNode(returnTypeNode); + var promisedType = checker.getAwaitedType(returnType) || checker.getVoidType(); + var promisedTypeNode = checker.typeToTypeNode(promisedType, /*enclosingDeclaration*/ returnTypeNode, /*flags*/ undefined); + if (promisedTypeNode) { + return { returnTypeNode: returnTypeNode, returnType: returnType, promisedTypeNode: promisedTypeNode, promisedType: promisedType }; + } + } + function doChange(changes, sourceFile, returnTypeNode, promisedTypeNode) { + changes.replaceNode(sourceFile, returnTypeNode, ts.createTypeReferenceNode("Promise", [promisedTypeNode])); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -137237,7 +137445,6 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: - case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 967aad4ef5b36..aec6e4ed0c096 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -81,9 +81,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.9"; + ts.versionMajorMinor = "4.0"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.2"; + ts.version = ts.versionMajorMinor + ".0-dev"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -6700,7 +6700,7 @@ var ts; Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise<{0}>'?"), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), @@ -7385,6 +7385,8 @@ var ts; Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), + The_operand_of_a_delete_operator_must_be_optional: diag(2790, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_optional_2790", "The operand of a 'delete' operator must be optional."), + Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later: diag(2791, ts.DiagnosticCategory.Error, "Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_lat_2791", "Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -7937,6 +7939,8 @@ var ts; Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), + Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"), + Fix_all_incorrect_return_type_of_an_async_functions: diag(90037, ts.DiagnosticCategory.Message, "Fix_all_incorrect_return_type_of_an_async_functions_90037", "Fix all incorrect return type of an async functions"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -14674,7 +14678,7 @@ var ts; } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). - * We treat the right hand side of assignments with container-like initalizers as declarations. + * We treat the right hand side of assignments with container-like initializers as declarations. */ function getAssignedExpandoInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -16551,11 +16555,9 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { - // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { - // eslint-disable-next-line setAccessor = member; } } @@ -31067,7 +31069,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -31088,7 +31090,7 @@ var ts; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 162 /* Constructor */) { + if (node.kind === 162 /* Constructor */ || (ts.isInJSFile && (node.kind === 244 /* FunctionDeclaration */ || node.kind === 201 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -33197,7 +33199,7 @@ var ts; } function bindSpecialPropertyAssignment(node) { // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } @@ -33210,13 +33212,15 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } - else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -33224,7 +33228,6 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { - ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -33296,7 +33299,7 @@ var ts; : propertyAccess.parent.parent.kind === 290 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { - var namespaceSymbol = lookupSymbolForPropertyAccess(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); @@ -34996,6 +34999,7 @@ var ts; }, getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, + getAwaitedType: function (type) { return getAwaitedType(type); }, getReturnTypeOfSignature: getReturnTypeOfSignature, isNullableType: isNullableType, getNullableType: getNullableType, @@ -35371,6 +35375,7 @@ var ts; /** Key is "/path/to/a.ts|/path/to/b.ts". */ var amalgamatedDuplicates; var reverseMappedCache = ts.createMap(); + var inInferTypeForHomomorphicMappedType = false; var ambientModulesCache; /** * List of every ambient module with a "*" wildcard. @@ -35896,7 +35901,7 @@ var ts; var sourceFiles = host.getSourceFiles(); return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } - if (declaration.pos <= usage.pos) { + if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage if (declaration.kind === 191 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) @@ -36985,8 +36990,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var _a; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -39680,9 +39685,6 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } - function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { - return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); - } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39693,7 +39695,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + if (getTypeFromTypeNode(existing) === type) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39713,7 +39715,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39753,16 +39755,6 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } - if (ts.isJSDocTypeLiteral(node)) { - return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { - var name = ts.isIdentifier(t.name) ? t.name : t.name.right; - var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); - var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; - return ts.createPropertySignature( - /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), - /*initializer*/ undefined); - })); - } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39790,9 +39782,6 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { - return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); - } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -41485,6 +41474,15 @@ var ts; var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration)); return addOptionality(type, isOptional); } + if (ts.isPropertyDeclaration(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) { + // We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file. + // Use control flow analysis of this.xxx assignments the constructor to determine the type of the property. + var constructor = findConstructorDeclaration(declaration.parent); + var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : + ts.getModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + undefined; + return type && addOptionality(type, isOptional); + } if (ts.isJsxAttribute(declaration)) { // if JSX attribute doesn't have initializer, by default the attribute will have boolean value of true. // I.e is sugar for @@ -41498,6 +41496,56 @@ var ts; // No type specified and nothing can be inferred return undefined; } + function isConstructorDeclaredProperty(symbol) { + // A propery is considered a constructor declared property when all declaration sites are this.xxx assignments, + // when no declaration sites have JSDoc type annotations, and when at least one declaration site is in the body of + // a class constructor. + if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) { + var links = getSymbolLinks(symbol); + if (links.isConstructorDeclaredProperty === undefined) { + links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { + return ts.isBinaryExpression(declaration) && + ts.getAssignmentDeclarationKind(declaration) === 4 /* ThisProperty */ && + (declaration.left.kind !== 195 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); + }); + } + return links.isConstructorDeclaredProperty; + } + return false; + } + function isAutoTypedProperty(symbol) { + // A property is auto-typed when its declaration has no type annotation or initializer and we're in + // noImplicitAny mode or a .js file. + var declaration = symbol.valueDeclaration; + return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) && + !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); + } + function getDeclaringConstructor(symbol) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var container = ts.getThisContainer(declaration, /*includeArrowFunctions*/ false); + if (container && (container.kind === 162 /* Constructor */ || isJSConstructor(container))) { + return container; + } + } + } + function getFlowTypeInConstructor(symbol, constructor) { + var reference = ts.createPropertyAccess(ts.createThis(), ts.unescapeLeadingUnderscores(symbol.escapedName)); + reference.expression.parent = reference; + reference.parent = constructor; + reference.flowNode = constructor.returnFlowNode; + var flowType = getFlowTypeOfProperty(reference, symbol); + if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) { + error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); + } + // We don't infer a type if assignments are only null or undefined. + return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); + } + function getFlowTypeOfProperty(reference, prop) { + var initialType = prop && (!isAutoTypedProperty(prop) || ts.getModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + return getFlowTypeOfReference(reference, autoType, initialType); + } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { // function/class/{} initializers are themselves containers, so they won't merge in the same way as other initializers var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration); @@ -41509,52 +41557,60 @@ var ts; var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } + var type; var definedInConstructor = false; var definedInMethod = false; - var jsdocType; - var types; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; - } - else { - definedInMethod = true; - } - } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + // We use control flow analysis to determine the type of the property if the property qualifies as a constructor + // declared property and the resulting control flow type isn't just undefined or null. + if (isConstructorDeclaredProperty(symbol)) { + type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } - var type = jsdocType; if (!type) { - if (!ts.length(types)) { - return errorType; // No types from any declarations :( + var jsdocType = void 0; + var types = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere + } + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); + } } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; - // use only the constructor types unless they were only assigned null | undefined (including widening variants) - if (definedInMethod) { - var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); - if (propType) { - (constructorTypes || (constructorTypes = [])).push(propType); - definedInConstructor = true; + type = jsdocType; + if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } + var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + // use only the constructor types unless they were only assigned null | undefined (including widening variants) + if (definedInMethod) { + var propType = getTypeOfPropertyInBaseClass(symbol); + if (propType) { + (constructorTypes || (constructorTypes = [])).push(propType); + definedInConstructor = true; + } } + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + type = getUnionType(sourceTypes, 2 /* Subtype */); } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 - type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { @@ -41709,20 +41765,6 @@ var ts; return expression && isDeclarationInConstructor(expression); }); } - /** check for definition in base class if any declaration is in a class */ - function getTypeOfAssignmentDeclarationPropertyOfBaseType(property) { - var parentDeclaration = ts.forEach(property.declarations, function (d) { - var parent = ts.getThisContainer(d, /*includeArrowFunctions*/ false).parent; - return ts.isClassLike(parent) && parent; - }); - if (parentDeclaration) { - var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(parentDeclaration)); - var baseClassType = classType && getBaseTypes(classType)[0]; - if (baseClassType) { - return getTypeOfPropertyOfType(baseClassType, property.escapedName); - } - } - } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. @@ -46363,6 +46405,9 @@ var ts; if (accessFlags & 4 /* CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } + if (isThisPropertyAccessInConstructor(accessExpression, prop)) { + return autoType; + } } var propType = getTypeOfSymbol(prop); return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? @@ -47666,7 +47711,7 @@ var ts; return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper) { + if (!(type && mapper && couldContainTypeVariables(type))) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -47700,37 +47745,23 @@ var ts; } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; - if (objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. - return couldContainTypeVariables(type) ? - getObjectTypeInstantiation(type, mapper) : type; - } - if (objectFlags & 32 /* Mapped */) { - return getObjectTypeInstantiation(type, mapper); - } - if (objectFlags & 4 /* Reference */) { - if (type.node) { - return getObjectTypeInstantiation(type, mapper); + if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { + if (objectFlags & 4 /* Reference */ && !(type.node)) { + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } - var resolvedTypeArguments = type.resolvedTypeArguments; - var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); - return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; + return getObjectTypeInstantiation(type, mapper); } return type; } - if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { - if (!couldContainTypeVariables(type)) { - return type; - } + if (flags & 3145728 /* UnionOrIntersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes === types - ? type - : (flags & 2097152 /* Intersection */) - ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) - : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + return newTypes === types ? type : + flags & 2097152 /* Intersection */ ? + getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : + getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -49132,7 +49163,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -50688,6 +50719,12 @@ var ts; function getDeclaringClass(prop) { return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; } + // Return the inherited type of the given property or undefined if property doesn't exist in a base class. + function getTypeOfPropertyInBaseClass(property) { + var classType = getDeclaringClass(property); + var baseClassType = classType && getBaseTypes(classType)[0]; + return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName); + } // Return true if some underlying source property is declared in a class that derives // from the given base class. function isPropertyInClassDerivedFrom(prop, baseClass) { @@ -51539,15 +51576,22 @@ var ts; return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); } var result = !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || - objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } return result; } + function isNonGenericTopLevelType(type) { + if (type.aliasSymbol && !type.aliasTypeArguments) { + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 247 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 290 /* SourceFile */ ? true : n.kind === 249 /* ModuleDeclaration */ ? false : "quit"; })); + } + return false; + } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || @@ -51580,12 +51624,16 @@ var ts; * variable T[P] (i.e. we treat the type T[P] as the type variable we're inferring for). */ function inferTypeForHomomorphicMappedType(source, target, constraint) { + if (inInferTypeForHomomorphicMappedType) { + return undefined; + } var key = source.id + "," + target.id + "," + constraint.id; if (reverseMappedCache.has(key)) { return reverseMappedCache.get(key); } - reverseMappedCache.set(key, undefined); + inInferTypeForHomomorphicMappedType = true; var type = createReverseMappedType(source, target, constraint); + inInferTypeForHomomorphicMappedType = false; reverseMappedCache.set(key, type); return type; } @@ -53320,7 +53368,7 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); + var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { @@ -53374,7 +53422,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); + var type = getTypeFromFlowType(flowType); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -53603,14 +53651,15 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - if (!(computedType.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { + var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; + if (!(type.flags & 1048576 /* Union */) || !ts.isAccessExpression(expr)) { return false; } var name = getAccessedPropertyName(expr); if (name === undefined) { return false; } - return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, name); + return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name); } function narrowTypeByDiscriminant(type, access, narrowType) { var propName = getAccessedPropertyName(access); @@ -53634,7 +53683,7 @@ var ts; if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } return type; @@ -53687,10 +53736,10 @@ var ts; type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, declaredType)) { + if (isMatchingReferenceDiscriminant(left_1, type)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } - if (isMatchingReferenceDiscriminant(right_1, declaredType)) { + if (isMatchingReferenceDiscriminant(right_1, type)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } if (isMatchingConstructorReference(left_1)) { @@ -54084,7 +54133,7 @@ var ts; !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + if (isMatchingReferenceDiscriminant(predicateArgument, type)) { return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } @@ -54124,7 +54173,7 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); } - if (isMatchingReferenceDiscriminant(expr, declaredType)) { + if (isMatchingReferenceDiscriminant(expr, type)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); } return type; @@ -54660,6 +54709,10 @@ var ts; var fileSymbol = getSymbolOfNode(container); return fileSymbol && getTypeOfSymbol(fileSymbol); } + else if (container.externalModuleIndicator) { + // TODO: Maybe issue a better error than 'object is possibly undefined' + return undefinedType; + } else if (includeGlobalThis) { return getTypeOfSymbol(globalThisSymbol); } @@ -56917,6 +56970,9 @@ var ts; } return false; } + function isThisPropertyAccessInConstructor(node, prop) { + return ts.isThisProperty(node) && (isAutoTypedProperty(prop) || isConstructorDeclaredProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); + } function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); @@ -56990,7 +57046,7 @@ var ts; error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); } return getFlowTypeOfAccessExpression(node, prop, propType, right); } @@ -57004,6 +57060,9 @@ var ts; prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; } + if (propType === autoType) { + return getFlowTypeOfProperty(node, prop); + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -60099,17 +60158,25 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } - // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } var links = getNodeLinks(expr); var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol); - if (symbol && isReadonlySymbol(symbol)) { - error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + if (symbol) { + if (isReadonlySymbol(symbol)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property); + } + checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol)); } return booleanType; } + function checkDeleteExpressionMustBeOptional(expr, type) { + var AnyOrUnknownOrNeverFlags = 3 /* AnyOrUnknown */ | 131072 /* Never */; + if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768 /* Undefined */)) { + error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); + } + } function checkTypeOfExpression(node) { checkExpression(node.expression); return typeofType; @@ -60319,7 +60386,8 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 296 /* NumberLike */ | 12288 /* ESSymbolLike */))) { + if (!(allTypesAssignableToKind(leftType, 132 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 262144 /* TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { @@ -60704,6 +60772,12 @@ var ts; case 49 /* GreaterThanGreaterThanGreaterThanToken */: case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); + break; + case 42 /* AsteriskAsteriskToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ES2016 */) { + error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); + } } resultType_1 = bigintType; } @@ -62826,7 +62900,7 @@ var ts; if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); return; } } @@ -68476,9 +68550,9 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer); } } - else if (parameter.questionToken) { + else if (isOptionalParameter(parameter)) { seenOptionalParameter = true; - if (parameter.initializer) { + if (parameter.questionToken && parameter.initializer) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer); } } @@ -70863,9 +70937,11 @@ var ts; } ts.createBinary = createBinary; function updateBinary(node, left, right, operator) { + if (operator === void 0) { operator = node.operatorToken; } return node.left !== left || node.right !== right - ? updateNode(createBinary(left, operator || node.operatorToken, right), node) + || node.operatorToken !== operator + ? updateNode(createBinary(left, operator, right), node) : node; } ts.updateBinary = updateBinary; @@ -100669,11 +100745,11 @@ var ts; return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); } function getMergedProgramDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -100746,11 +100822,11 @@ var ts; }); } function getMergedBindAndCheckDiagnostics(sourceFile) { - var _a; var allDiagnostics = []; for (var _i = 1; _i < arguments.length; _i++) { allDiagnostics[_i - 1] = arguments[_i]; } + var _a; var flatDiagnostics = ts.flatten(allDiagnostics); if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { return flatDiagnostics; @@ -104062,8 +104138,8 @@ var ts; return primaryResult; } function resolveNamesWithLocalCache(_a) { - var _b; var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; + var _b; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -108319,7 +108395,8 @@ var ts; } _this.delayedInitializationError = { kind: "event::initializationFailed", - message: e.message + message: e.message, + stack: e.stack, }; } _this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), _this.installTypingHost, _this.log); @@ -108438,7 +108515,9 @@ var ts; var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, validateDefaultNpmLocation, 5, log); installer.listen(); function indent(newline, str) { - return newline + " " + str.replace(/\r?\n/, newline + " "); + return str && str.length + ? newline + " " + str.replace(/\r?\n/, newline + " ") + : ""; } })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index ba86d975816d3..ee773c076cc42 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "无法解析具有表达式的路径“{0}”: {1}。", "Could_not_write_file_0_Colon_1_5033": "无法写入文件“{0}”: {1}。", "DIRECTORY_6038": "目录", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "该声明扩充了另一文件中的声明。这无法被序列化。", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "此文件的声明发出要求使用专用名称 \"{0}\"。显式类型注释可能取消阻止声明发出。", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "此文件的声明发出要求使用模块 \"{1}\" 中的专用名称 \"{0}\"。显式类型注释可能取消阻止声明发出。", "Declaration_expected_1146": "应为声明。", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "初始化构造函数中的属性“{0}”", "Initialize_static_property_0_90021": "初始化静态属性“{0}”", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "实例成员变量“{0}”的初始化表达式不能引用构造函数中声明的标识符“{1}”。", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "参数“{0}”的初始化表达式不能引用在它之后声明的标识符“{1}”。", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "初始化表达式没有为此绑定元素提供此任何值,且该绑定元素没有默认值。", "Initializers_are_not_allowed_in_ambient_contexts_1039": "不允许在环境上下文中使用初始化表达式。", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "初始化 TypeScript 项目并创建 tsconfig.json 文件。", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "重载签名必须均导出或均不导出。", "Overload_signatures_must_all_be_optional_or_required_2386": "重载签名必须全部为可选签名或必需签名。", "Overload_signatures_must_all_be_public_private_or_protected_2385": "重载签名必须全部是公共签名、私有签名或受保护签名。", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "参数“{0}”的初始化表达式中不能引用该参数自身。", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "参数“{0}”不能引用在它之后声明的标识符“{1}”。", + "Parameter_0_cannot_reference_itself_2372": "参数“{0}”不能引用它自身。", "Parameter_0_implicitly_has_an_1_type_7006": "参数“{0}”隐式具有“{1}”类型。", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "参数 \"{0}\" 隐式具有 \"{1}\" 类型,但可以从用法中推断出更好的类型。", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "参数“{0}”和参数“{1}”的位置不一样。", @@ -1147,6 +1148,7 @@ "This_expression_is_not_callable_2349": "此表达式不可调用。", "This_expression_is_not_constructable_2351": "此表达式不可构造。", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "此导入从不用作值,必须使用 \"import type\" ,因为 \"importsNotUsedAsValues\" 设置为 \"error\"。", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "这是正在扩充的声明。请考虑将扩充声明移到同一个文件中。", "This_may_be_converted_to_an_async_function_80006": "可将此转换为异步函数。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能通过启用 \"{0}\" 标志并引用其默认导出,使用 ECMAScript 导入/导出来引用此模块。", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "此模块是使用 \"export =\" 声明的,在使用 \"{0}\" 标志时只能与默认导入一起使用。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index cc2fb989e7969..43c3bd2b02bd0 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -395,6 +395,7 @@ "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231": "無法解析具有下列延伸模組的路徑 '{0}': {1}。", "Could_not_write_file_0_Colon_1_5033": "無法編寫檔案 '{0}': {1}。", "DIRECTORY_6038": "目錄", + "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232": "宣告會讓另一個檔案中的宣告增加。這無法序列化。", "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005": "此檔案的宣告發出必須使用私人名稱 '{0}'。明確的型別註解可能會解除封鎖宣告發出。", "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006": "此檔案的宣告發出必須使用來自模組 '{1}' 的私人名稱 '{0}'。明確的型別註解可能會解除封鎖宣告發出。", "Declaration_expected_1146": "必須是宣告。", @@ -631,7 +632,6 @@ "Initialize_property_0_in_the_constructor_90020": "將建構函式中的屬性 '{0}' 初始化", "Initialize_static_property_0_90021": "將靜態屬性 '{0}' 初始化", "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301": "執行個體成員變數 '{0}' 的初始設定式不得參考建構函式中所宣告的識別碼 '{1}'。", - "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "參數 '{0}' 的初始設定式不得參考在其之後宣告的識別碼 '{1}'。", "Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value_2525": "初始設定式未提供任何值給這個繫結項目,且該繫結項目沒有預設值。", "Initializers_are_not_allowed_in_ambient_contexts_1039": "環境內容中不得有初始設定式。", "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070": "初始化 TypeScript 專案並建立 tsconfig.json 檔案。", @@ -808,7 +808,8 @@ "Overload_signatures_must_all_be_exported_or_non_exported_2383": "多載簽章必須全部匯出或不匯出。", "Overload_signatures_must_all_be_optional_or_required_2386": "多載簽章都必須是選擇性或必要簽章。", "Overload_signatures_must_all_be_public_private_or_protected_2385": "多載簽章必須是公用、私用或受保護。", - "Parameter_0_cannot_be_referenced_in_its_initializer_2372": "無法在參數 '{0}' 的初始設定式中參考此參數。", + "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373": "參數 '{0}' 不得參考在其之後宣告的識別碼 '{1}'。", + "Parameter_0_cannot_reference_itself_2372": "參數 '{0}' 不得參考自身。", "Parameter_0_implicitly_has_an_1_type_7006": "參數 '{0}' 隱含了 '{1}' 類型。", "Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7044": "參數 '{0}' 隱含 '{1}' 類型,但可從使用方式推斷更適合的類型。", "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227": "參數 '{0}' 與參數 '{1}' 不在同一個位置。", @@ -1108,6 +1109,7 @@ "The_operand_of_a_delete_operator_cannot_be_a_private_identifier_18011": "'delete' 運算子的運算元不可為私人識別碼。", "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704": "'delete' 運算子的運算元不可為唯讀屬性。", "The_operand_of_a_delete_operator_must_be_a_property_reference_2703": "'delete' 運算子的運算元必須為屬性參考。", + "The_operand_of_a_delete_operator_must_be_optional_2790": "'delete' 運算子的運算元必須是非必須。", "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777": "遞增或遞減運算子的運算元不可為選擇性屬性存取。", "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357": "遞增或遞減運算子的運算元必須是變數或屬性存取。", "The_parser_expected_to_find_a_to_match_the_token_here_1007": "剖析器需找到可與此處 '{' 語彙基元搭配的 '}'。", @@ -1146,6 +1148,7 @@ "This_expression_is_not_callable_2349": "無法呼叫此運算式。", "This_expression_is_not_constructable_2351": "無法建構此運算式。", "This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is__1371": "因為 'importsNotUsedAsValues' 設定為 'error',所以此匯入永遠不會作為值使用,而且必須使用 'import type'。", + "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233": "此宣告正在增加中。請考慮將正在增加的宣告移至相同的檔案中。", "This_may_be_converted_to_an_async_function_80006": "這可以轉換為非同步函式。", "This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_2497": "只能以 ECMAScript 匯入/匯出來參考此模組,方法為開啟 '{0}' 旗標並參考其預設匯出。", "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594": "此模組使用 'export =' 宣告,而且在使用 '{0}' 旗標時,只能搭配預設匯入使用。",